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 run commands as root | |
| sudo whoami | |
| EMPTY_ADB_OUTPUT="List of devices attached" | |
| NO_PERMISSIONS="no permissions" | |
| LAST_ADB_OUTPUT="" | |
| while true | |
| do | |
| ADB_OUTPUT=$(adb devices) |
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 | |
| protected void onStart() { | |
| super.onStart(); | |
| adapter.startListening(); | |
| } | |
| @Override | |
| protected void onStop() { | |
| super.onStop(); | |
| adapter.stopListening(); |
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 void fetch() { | |
| Query query = FirebaseDatabase.getInstance() | |
| .getReference() | |
| .child("posts"); | |
| FirebaseRecyclerOptions<Model> options = | |
| new FirebaseRecyclerOptions.Builder<Model>() | |
| .setQuery(query, new SnapshotParser<Model>() { | |
| @NonNull | |
| @Override |
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
| public class ViewHolder extends RecyclerView.ViewHolder { | |
| public LinearLayout root; | |
| public TextView txtTitle; | |
| public TextView txtDesc; | |
| public ViewHolder(View itemView) { | |
| super(itemView); | |
| root = itemView.findViewById(R.id.list_root); | |
| txtTitle = itemView.findViewById(R.id.list_title); | |
| txtDesc = itemView.findViewById(R.id.list_desc); |
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
| linearLayoutManager = new LinearLayoutManager(this); | |
| recyclerView.setLayoutManager(linearLayoutManager); | |
| recyclerView.setHasFixedSize(true); | |
| fetch(); |
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
| button.setOnClickListener(new View.OnClickListener() { | |
| @Override | |
| public void onClick(View view) { | |
| DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference().child("posts").push(); | |
| Map<String, Object> map = new HashMap<>(); | |
| map.put("id", databaseReference.getKey()); | |
| map.put("title", editText.getText().toString()); | |
| map.put("desc", etd.getText().toString()); | |
| databaseReference.setValue(map); |
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
| editText = findViewById(R.id.et); | |
| etd = findViewById(R.id.etd); | |
| button = findViewById(R.id.btn); | |
| recyclerView = findViewById(R.id.list); |
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 EditText editText, etd; | |
| private Button button; | |
| private RecyclerView recyclerView; | |
| private LinearLayoutManager linearLayoutManager; | |
| private FirebaseRecyclerAdapter adapter; |
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
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:orientation="vertical" | |
| tools:context=".MainActivity"> | |
| <LinearLayout |
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
| <?xml version="1.0" encoding="utf-8"?> | |
| <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:layout_marginBottom="8dp" | |
| android:layout_marginEnd="16dp" | |
| android:layout_marginLeft="16dp" | |
| android:layout_marginRight="16dp" | |
| android:layout_marginStart="16dp" | |
| android:layout_marginTop="8dp"> |
NewerOlder