Skip to content
Snippets Groups Projects
Commit df625ab1 authored by Andrej Rasevic's avatar Andrej Rasevic
Browse files

adding firebase lecture CRUD demo

parent e28d41f8
No related branches found
No related tags found
No related merge requests found
Showing
with 853 additions and 0 deletions
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
File added
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="5">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
/build
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.tesla.myhomelibrary"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-database:16.0.3'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
implementation 'com.android.support:support-annotations:28.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
}
apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
{
"project_info": {
"project_number": "29102789333",
"firebase_url": "https://myhomelibrary-838ac.firebaseio.com",
"project_id": "myhomelibrary-838ac",
"storage_bucket": "myhomelibrary-838ac.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:29102789333:android:7f079efdba385b39",
"android_client_info": {
"package_name": "com.example.tesla.myhomelibrary"
}
},
"oauth_client": [
{
"client_id": "29102789333-b0jc7do4lghpm5oo3panm8rgcqrco9at.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCYVtTDVxur-80vXj37SRHPAvhQeSX8L6U"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.example.tesla.myhomelibrary;
import android.support.test.espresso.ViewInteraction;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
@LargeTest
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class);
@Test
public void mainActivityTest() {
// Added a sleep statement to match the app's execution delay.
// The recommended way to handle such scenarios is to use Espresso idling resources:
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(30000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ViewInteraction textView = onView(
allOf(withId(R.id.textView), withText("Authors"),
childAtPosition(
allOf(withId(R.id.activity_main),
childAtPosition(
withId(android.R.id.content),
0)),
3),
isDisplayed()));
textView.check(matches(withText("Authors")));
ViewInteraction button = onView(
allOf(withId(R.id.buttonAddAuthor),
childAtPosition(
allOf(withId(R.id.activity_main),
childAtPosition(
withId(android.R.id.content),
0)),
2),
isDisplayed()));
button.check(matches(isDisplayed()));
ViewInteraction textView2 = onView(
allOf(withId(R.id.textViewName), withText("Ernesto Hemingway"),
childAtPosition(
childAtPosition(
withId(R.id.listViewAuthors),
0),
0),
isDisplayed()));
textView2.check(matches(withText("Ernesto Hemingway")));
}
private static Matcher<View> childAtPosition(
final Matcher<View> parentMatcher, final int position) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("Child at position " + position + " in parent ");
parentMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
return parent instanceof ViewGroup && parentMatcher.matches(parent)
&& view.equals(((ViewGroup) parent).getChildAt(position));
}
};
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tesla.myhomelibrary">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AuthorActivity"></activity>
</application>
</manifest>
\ No newline at end of file
package com.example.tesla.myhomelibrary;
import com.google.firebase.database.IgnoreExtraProperties;
@IgnoreExtraProperties
public class Author {
private String authorId;
private String authorName;
private String authorCountry;
public Author(){
//this constructor is required
}
public Author(String authorId, String authorName, String authorCountry) {
this.authorId = authorId;
this.authorName = authorName;
this.authorCountry = authorCountry;
}
public String getAuthorId() {
return authorId;
}
public String getAuthorName() { return authorName; }
public String getAuthorCountry() {
return authorCountry;
}
}
\ No newline at end of file
package com.example.tesla.myhomelibrary;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.List;
public class AuthorActivity extends AppCompatActivity {
Button buttonAddTitle;
EditText editTextTitleName;
SeekBar seekBarRating;
TextView textViewRating, textViewAuthor;
ListView listViewTitles;
DatabaseReference databaseTitles;
List<Title> titles;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_author);
Intent intent = getIntent();
/*
* this line is important
* this time we are not getting the reference of a direct node
* but inside the node track we are creating a new child with the author id
* and inside that node we will store all the titles with unique ids
* */
databaseTitles = FirebaseDatabase.getInstance().getReference("titles").child(intent.getStringExtra(MainActivity.AUTHOR_ID));
buttonAddTitle = (Button) findViewById(R.id.buttonAddTitle);
editTextTitleName = (EditText) findViewById(R.id.editTextName);
seekBarRating = (SeekBar) findViewById(R.id.seekBarRating);
textViewRating = (TextView) findViewById(R.id.textViewRating);
textViewAuthor = (TextView) findViewById(R.id.textViewAuthor);
listViewTitles = (ListView) findViewById(R.id.listViewTitles);
titles = new ArrayList<Title>();
textViewAuthor.setText(intent.getStringExtra(MainActivity.AUTHOR_NAME));
seekBarRating.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
textViewRating.setText(String.valueOf(i));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
buttonAddTitle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
saveTitle();
}
});
}
@Override
protected void onStart() {
super.onStart();
databaseTitles.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
titles.clear();
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
Title title = postSnapshot.getValue(Title.class);
titles.add(title);
}
TitleList titleListAdapter = new TitleList(AuthorActivity.this, titles);
listViewTitles.setAdapter(titleListAdapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
private void saveTitle() {
String titleName = editTextTitleName.getText().toString().trim();
int rating = seekBarRating.getProgress();
if (!TextUtils.isEmpty(titleName)) {
String id = databaseTitles.push().getKey();
Title title = new Title(id, titleName, rating);
databaseTitles.child(id).setValue(title);
Toast.makeText(this, "Title saved", Toast.LENGTH_LONG).show();
editTextTitleName.setText("");
} else {
Toast.makeText(this, "Please enter title name", Toast.LENGTH_LONG).show();
}
}
}
package com.example.tesla.myhomelibrary;
import android.app.Activity;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.List;
public class AuthorList extends ArrayAdapter<Author> {
private Activity context;
List<Author> authors;
public AuthorList(Activity context, List<Author> authors) {
super(context, R.layout.layout_author_list, authors);
this.context = context;
this.authors = authors;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.layout_author_list, null, true);
TextView textViewName = (TextView) listViewItem.findViewById(R.id.textViewName);
TextView textViewCountry = (TextView) listViewItem.findViewById(R.id.textViewCountry);
Author author = authors.get(position);
textViewName.setText(author.getAuthorName());
textViewCountry.setText(author.getAuthorCountry());
return listViewItem;
}
}
\ No newline at end of file
package com.example.tesla.myhomelibrary;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
public static final String AUTHOR_NAME = "com.example.tesla.myhomelibrary.authorname";
public static final String AUTHOR_ID = "com.example.tesla.myhomelibrary.authorid";
EditText editTextName;
Spinner spinnerCountry;
Button buttonAddAuthor;
ListView listViewAuthors;
//a list to store all the artist from firebase database
List<Author> authors;
//our database reference object
DatabaseReference databaseAuthors;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//getting the reference of artists node
databaseAuthors = FirebaseDatabase.getInstance().getReference("authors");
//getting views
editTextName = (EditText) findViewById(R.id.editTextName);
spinnerCountry = (Spinner) findViewById(R.id.spinnerCountry);
listViewAuthors = (ListView) findViewById(R.id.listViewAuthors);
buttonAddAuthor = (Button) findViewById(R.id.buttonAddAuthor);
//list to store authors
authors = new ArrayList<>();
//adding an onclicklistener to button
buttonAddAuthor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//calling the method addArtist()
//the method is defined below
//this method is actually performing the write operation
addAuthor();
}
});
//attaching listener to listview
listViewAuthors.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
//getting the selected artist
Author author = authors.get(i);
//creating an intent
Intent intent = new Intent(getApplicationContext(), AuthorActivity.class);
//putting artist name and id to intent
intent.putExtra(AUTHOR_ID, author.getAuthorId());
intent.putExtra(AUTHOR_NAME, author.getAuthorName());
//starting the activity with intent
startActivity(intent);
}
});
listViewAuthors.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
Author author = authors.get(i);
showUpdateDeleteDialog(author.getAuthorId(), author.getAuthorName());
return true;
}
});
}
private void showUpdateDeleteDialog(final String authorId, String authorName) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.update_dialog, null);
dialogBuilder.setView(dialogView);
final EditText editTextName = (EditText) dialogView.findViewById(R.id.editTextName);
final Spinner spinnerCountry = (Spinner) dialogView.findViewById(R.id.spinnerCountry);
final Button buttonUpdate = (Button) dialogView.findViewById(R.id.buttonUpdateAuthor);
final Button buttonDelete = (Button) dialogView.findViewById(R.id.buttonDeleteAuthor);
dialogBuilder.setTitle(authorName);
final AlertDialog b = dialogBuilder.create();
b.show();
buttonUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String name = editTextName.getText().toString().trim();
String country = spinnerCountry.getSelectedItem().toString();
if (!TextUtils.isEmpty(name)) {
updateAuthor(authorId, name, country);
b.dismiss();
}
}
});
buttonDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
deleteAuthor(authorId);
b.dismiss();
}
});
}
private boolean updateAuthor(String id, String name, String country) {
//getting the specified author reference
DatabaseReference dR = FirebaseDatabase.getInstance().getReference("authors").child(id);
//updating author
Author author = new Author(id, name, country);
dR.setValue(author);
Toast.makeText(getApplicationContext(), "Author Updated", Toast.LENGTH_LONG).show();
return true;
}
private boolean deleteAuthor(String id) {
//getting the specified author reference
DatabaseReference dR = FirebaseDatabase.getInstance().getReference("authors").child(id);
//removing author
dR.removeValue();
//getting the titles reference for the specified author
DatabaseReference drTitles = FirebaseDatabase.getInstance().getReference("titles").child(id);
//removing all titles
drTitles.removeValue();
Toast.makeText(getApplicationContext(), "Author Deleted", Toast.LENGTH_LONG).show();
return true;
}
@Override
protected void onStart() {
super.onStart();
//attaching value event listener
databaseAuthors.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//clearing the previous artist list
authors.clear();
//iterating through all the nodes
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
//getting artist
Author author = postSnapshot.getValue(Author.class);
//adding author to the list
authors.add(author);
}
//creating adapter
AuthorList authorAdapter = new AuthorList(MainActivity.this, authors);
//attaching adapter to the listview
listViewAuthors.setAdapter(authorAdapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
/*
* This method is saving a new author to the
* Firebase Realtime Database
* */
private void addAuthor() {
//getting the values to save
String name = editTextName.getText().toString().trim();
String country = spinnerCountry.getSelectedItem().toString();
//checking if the value is provided
if (!TextUtils.isEmpty(name)) {
//getting a unique id using push().getKey() method
//it will create a unique id and we will use it as the Primary Key for our Author
String id = databaseAuthors.push().getKey();
//creating an Author Object
Author author = new Author(id, name, country);
//Saving the Author
databaseAuthors.child(id).setValue(author);
//setting edittext to blank again
editTextName.setText("");
//displaying a success toast
Toast.makeText(this, "Author added", Toast.LENGTH_LONG).show();
} else {
//if the value is not given displaying a toast
Toast.makeText(this, "Please enter a name", Toast.LENGTH_LONG).show();
}
}
}
package com.example.tesla.myhomelibrary;
import com.google.firebase.database.IgnoreExtraProperties;
@IgnoreExtraProperties
public class Title {
private String id;
private String titleName;
private int rating;
public Title() {
}
public Title(String id, String titleName, int rating) {
this.titleName = titleName;
this.rating = rating;
this.id = id;
}
public String getTitleName() {
return titleName;
}
public int getRating() {
return rating;
}
}
package com.example.tesla.myhomelibrary;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.List;
public class TitleList extends ArrayAdapter<Title> {
private Activity context;
List<Title> titles;
public TitleList(Activity context, List<Title> titles) {
super(context, R.layout.layout_author_list, titles);
this.context = context;
this.titles = titles;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.layout_author_list, null, true);
TextView textViewName = (TextView) listViewItem.findViewById(R.id.textViewName);
TextView textViewRating = (TextView) listViewItem.findViewById(R.id.textViewCountry);
Title title = titles.get(position);
textViewName.setText(title.getTitleName());
textViewRating.setText(String.valueOf(title.getRating()));
return listViewItem;
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment