Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ dependencies {
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 'android.arch.lifecycle:extensions:1.1.1'
implementation 'android.arch.lifecycle:viewmodel:1.1.1'
implementation project(':congressdataapiaccess-debug')
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DetailsActivity"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.lambdaschool.congressdetails;

import android.arch.lifecycle.MutableLiveData;

import com.lambdaschool.congressdataapiaccess.CongressDao;
import com.lambdaschool.congressdataapiaccess.CongresspersonDetails;

import java.util.ArrayList;

public class CongressPersonDetailsRepo {

public static MutableLiveData<CongresspersonDetails> getDetails(String id) {
final MutableLiveData<CongresspersonDetails> liveDataList = new MutableLiveData<>();
CongresspersonDetails details = CongressDao.getMemberDetails(id);
liveDataList.setValue(details);
return liveDataList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.lambdaschool.congressdetails;

import android.arch.lifecycle.MutableLiveData;

import com.lambdaschool.congressdataapiaccess.CongressDao;
import com.lambdaschool.congressdataapiaccess.CongresspersonOverview;

import java.util.ArrayList;

public class CongressPersonOverviewRepo {

public static MutableLiveData<ArrayList<CongresspersonOverview>> getOverviewList() {
final MutableLiveData<ArrayList<CongresspersonOverview>> liveDataList = new MutableLiveData<>();

ArrayList<CongresspersonOverview> rawdata = CongressDao.getAllMembers();
liveDataList.setValue(rawdata);
return liveDataList;
}


}


Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.lambdaschool.congressdetails;

import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;

import com.lambdaschool.congressdataapiaccess.CongresspersonOverview;

import java.util.ArrayList;

public class CongressPersonViewModel extends ViewModel {

private MutableLiveData<ArrayList<CongresspersonOverview>> congressPersonDetailsList;


public LiveData<ArrayList<CongresspersonOverview>> getCongresspersonOverviewList(){
if(congressPersonDetailsList == null) {
loadlist();
}
return congressPersonDetailsList;
}

private void loadlist(){
congressPersonDetailsList = CongressPersonOverviewRepo.getOverviewList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.lambdaschool.congressdetails;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class DetailsActivity extends AppCompatActivity {

public static final String CONGRESS_DETAILS_KEY = "congress_details";


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,70 @@
package com.lambdaschool.congressdetails;

import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lambdaschool.congressdataapiaccess.CongresspersonDetails;
import com.lambdaschool.congressdataapiaccess.CongresspersonOverview;

import org.w3c.dom.Text;

import java.util.ArrayList;

public class ListActivity extends AppCompatActivity {


private Context context;
private LinearLayout listlayout;
private CongressPersonViewModel viewModel;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);

context = this;
listlayout = findViewById(R.id.list_layout);

viewModel = ViewModelProviders.of(this).get(CongressPersonViewModel.class);
final Observer<ArrayList<CongresspersonOverview>> observer = new Observer<ArrayList<CongresspersonOverview>>() {
@Override
public void onChanged(@Nullable ArrayList<CongresspersonOverview> congresspersonOverviews) {
if (congresspersonOverviews == null) {
refreshListView(congresspersonOverviews);
}
}
};

}

private TextView getDefaultTextView(final CongresspersonOverview congresspersonOverviews){
TextView textView = new TextView(context);
textView.setText(congresspersonOverviews.getFirstName() + " " + congresspersonOverviews.getLastName());
textView.setTextSize(18);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String id = congresspersonOverviews.getId();
Intent intent = new Intent(context, DetailsActivity.class);
//intent.putExtra(DetailsActivity.CONGRESS_DETAILS_KEY, congresspersonOverviews);
//startActivityForResult(intent, );
}
});
}

private void refreshListView(ArrayList<CongresspersonOverview> congresspersonOverviews) {
listlayout.removeAllViews();

for(CongresspersonOverview cpOverview : congresspersonOverviews){
//listlayout.addView();
}
}
}
29 changes: 29 additions & 0 deletions app/src/main/res/layout/activity_details.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".ListActivity">

<ScrollView
android:id="@+id/scrollView3"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent">

<LinearLayout
android:id="@+id/list_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >



</LinearLayout>

</ScrollView>



</android.support.constraint.ConstraintLayout>
27 changes: 19 additions & 8 deletions app/src/main/res/layout/activity_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@
android:layout_height="match_parent"
tools:context=".ListActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent">

<LinearLayout
android:id="@+id/list_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >



</LinearLayout>

</ScrollView>



</android.support.constraint.ConstraintLayout>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.1'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Sep 04 14:01:16 MDT 2018
#Thu Nov 08 13:55:48 PST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip