Когда я нажимаю на просмотр карты, приложение вылетает
, вот мой класс Java
`открытый класс CampaignActivity расширяет AppCompatActivity {
@BindView(R.id.progress_bar)
ProgressBar progressBar;
@BindView(R.id.campaign_list)
RecyclerView friendList;
private FirestoreRecyclerAdapter adapter;
private FirebaseFirestore db;
LinearLayoutManager linearLayoutManager;
Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_campaign);
toolbar = (Toolbar) findViewById(R.id.toolbar2);
setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Campaign");
ButterKnife.bind(this);
init();
getFriendList();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
//handle the click on the back arrow click
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void init() {
linearLayoutManager = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.VERTICAL, false);
friendList.setLayoutManager(linearLayoutManager);
db = FirebaseFirestore.getInstance();
}
private void getFriendList() {
Query query = db.collection("friends");
FirestoreRecyclerOptions<Response> response = new FirestoreRecyclerOptions.Builder<Response>()
.setQuery(query, Response.class)
.build();
adapter = new FirestoreRecyclerAdapter<Response, FriendsHolder>(response) {
@Override
protected void onBindViewHolder( FriendsHolder holder, int position, Response model) {
progressBar.setVisibility(View.GONE);
holder.textName.setText(model.getName());
holder.textTitle.setText(model.getTitle());
holder.textCompany.setText(model.getCompany());
Glide.with(getApplicationContext())
.load(model.getImage())
.into(holder.imageView);
}
@Override
public FriendsHolder onCreateViewHolder( ViewGroup group, int i) {
View view = LayoutInflater.from(group.getContext()).inflate(R.layout.campaigncard, group, false);
return new FriendsHolder(view);
}
};
adapter.notifyDataSetChanged();
friendList.setAdapter(adapter);
}
public class FriendsHolder extends RecyclerView.ViewHolder {
@BindView(R.id.name)
TextView textName;
@BindView(R.id.image)
CircleImageView imageView;
@BindView(R.id.title)
TextView textTitle;
@BindView(R.id.company)
TextView textCompany;
public FriendsHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}
@Override
public void onStart() {
super.onStart();
adapter.startListening();
}
@Override
public void onStop() {
super.onStop();
adapter.stopListening();
}
} ` Моя активность xml
<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:fitsSystemWindows="true"
tools:context=".CampaignActivity"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/campaign_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#00000000"/>
</RelativeLayout>
Мои зависимости
```apply plugin: 'com.google.gms.google-services'
```android {
compileSdkVersion 28
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
applicationId "com.example.bye"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-firestore:18.0.0'
implementation "com.firebaseui:firebase-ui-auth:3.0.0"
implementation 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.0'
implementation "com.google.android.gms:play-services-gcm:16.0.0"
implementation "com.firebaseui:firebase-ui-firestore:3.2.2"
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation "android.arch.lifecycle:reactivestreams:1.1.1"
implementation 'de.hdodenhof:circleimageview:2.0.0'
annotationProcessor 'android.arch.lifecycle:compiler:1.1.1'
implementation 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
}