Skip to content

Instantly share code, notes, and snippets.

@prakashpun
prakashpun / strings.xml
Created January 7, 2018 08:48
Add test AdMob app ID and ad unit IDs which has to be replaced later with live production ads for Admob account
<resources>
...
<string name="admob_app_id">ca-app-pub-3940256099942544~3347511713</string>
<string name="ad_unit_id">ca-app-pub-3940256099942544/5224354917</string>
...
</resources>
public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.CustomViewHolder> {
private List<RetroPhoto> dataList;
private Context context;
public CustomAdapter(Context context,List<RetroPhoto> dataList){
this.context = context;
this.dataList = dataList;
}
@prakashpun
prakashpun / MainActivity.java
Last active April 8, 2020 10:59
Initialize TextRecognizer and CameraSource
private void startCameraSource() {
//Create the TextRecognizer
final TextRecognizer textRecognizer = new TextRecognizer.Builder(getApplicationContext()).build();
if (!textRecognizer.isOperational()) {
Log.w(TAG, "Detector dependencies not loaded yet");
} else {
//Initialize camerasource to use high resolution and set Autofocus on.
@prakashpun
prakashpun / GetDataService.java
Created December 24, 2017 16:26
GetDataService.java
public interface GetDataService {
@GET("/photos")
Call<List<RetroPhoto>> getAllPhotos();
}
public class MainActivity extends AppCompatActivity {
private User user;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
user = new User();
user.setName("Prakash");
user.setEmail("praks@email.com");
public class MyHandlers {
public void btnClick(View view, User user) {
Toast.makeText(view.getContext(),"Name: "+user.getName() , Toast.LENGTH_LONG).show();
}
}
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="user"
type="com.tuts.prakash.databinding.model.User" />
<variable name="handler"
type="com.tuts.prakash.databinding.handlers.MyHandlers"/>
</data>
public class User {
private String name;
private String email;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
android {
dataBinding {
enabled = true
}
compileSdkVersion 27
.
.
.
}
<TextView
android:text="@{user.userName}" />