Commit 7366a38b authored by Robert Hitt's avatar Robert Hitt
Browse files

Clicking on a facility now opens its detail view

parent 48d39478
......@@ -10,13 +10,18 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.MainActivity">
<activity android:name=".ui.activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".ui.activities.DetailActivity">
<intent-filter>
<action android:name="android.intent.action.DETAIL"/>
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package srct.whatsopen.ui.activities;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.realm.Realm;
import srct.whatsopen.R;
import srct.whatsopen.model.Facility;
public class DetailActivity extends AppCompatActivity {
@BindView(R.id.facility_name) TextView nameTextView;
private Facility mFacility;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
ButterKnife.bind(this);
setUpViews(getIntent().getStringExtra("name"));
}
private void setUpViews(String key) {
// Get facility from Realm
Realm realm = Realm.getDefaultInstance();
mFacility = realm.where(Facility.class).equalTo("mName", key).findFirst();
realm.close();
nameTextView.setText(mFacility.getName());
}
}
package srct.whatsopen.ui;
package srct.whatsopen.ui.activities;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
......@@ -40,7 +42,6 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get WhatsOpenClient singleton
WhatsOpenService service = WhatsOpenClient.getInstance();
callWhatsOpenAPI(service);
......@@ -57,12 +58,6 @@ public class MainActivity extends AppCompatActivity {
viewPager.setCurrentItem(1);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
// does not work currently
/*
private void setDefaultTab(ViewPager viewPager) {
......
......@@ -2,6 +2,7 @@ package srct.whatsopen.ui.adapters;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
......@@ -11,7 +12,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
......@@ -22,6 +22,8 @@ import io.realm.Realm;
import io.realm.RealmRecyclerViewAdapter;
import srct.whatsopen.R;
import srct.whatsopen.model.Facility;
import srct.whatsopen.ui.activities.MainActivity;
import srct.whatsopen.ui.activities.DetailActivity;
/**
* Basic RecyclerView boilerplate, with some added Realm stuff
......@@ -85,11 +87,13 @@ public class FacilityListAdapter extends
ButterKnife.bind(this, itemView);
}
// should expand to the facility's detail view
// expands to the facility's detail view
@OnClick(R.id.text_layout)
public void expandFacilityView() {
String name = data.getName();
Toast.makeText(context, name + " clicked", Toast.LENGTH_SHORT).show();
Intent i = new Intent(context, DetailActivity.class);
i.putExtra("name", data.getName());
context.startActivity(i);
}
// toggles favorite status
......
......@@ -2,6 +2,7 @@ package srct.whatsopen.ui.fragments;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
......@@ -50,11 +51,15 @@ public class FacilityListFragment extends android.support.v4.app.Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_facility, container, false);
return inflater.inflate(R.layout.fragment_facility, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mRecyclerView = ButterKnife.findById(view, R.id.rvFacilities);
setUpRecyclerView(view);
return view;
}
// Handles set up for the Recycler View
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_detail"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/facility_name"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/activity_main"
android:id="@+id/fragment_facility"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="srct.whatsopen.ui.MainActivity">
tools:context="srct.whatsopen.ui.activities.MainActivity">
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/tabs"
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/activity_main"
android:id="@+id/fragment_facility"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment