Commit 6d27cb5c authored by Robert Hitt's avatar Robert Hitt
Browse files

Oops, forgot to add the actual changes

parent 9ce6e25d
package srct.whatsopen.ui;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.astuetz.PagerSlidingTabStrip;
......@@ -24,8 +20,6 @@ import butterknife.ButterKnife;
import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmResults;
import io.realm.Sort;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
......@@ -35,6 +29,7 @@ import srct.whatsopen.model.OpenTimes;
import srct.whatsopen.service.WhatsOpenClient;
import srct.whatsopen.service.WhatsOpenService;
import srct.whatsopen.model.Facility;
import srct.whatsopen.ui.adapters.FacilityListFragmentPagerAdapter;
public class MainActivity extends AppCompatActivity {
......@@ -59,7 +54,10 @@ public class MainActivity extends AppCompatActivity {
// Now give the TabStrip the ViewPager
PagerSlidingTabStrip tabStrip = ButterKnife.findById(this, R.id.tabs);
tabStrip.setTabPaddingLeftRight(0);
tabStrip.setViewPager(viewPager);
viewPager.setCurrentItem(1);
}
@Override
......@@ -68,6 +66,19 @@ public class MainActivity extends AppCompatActivity {
mRealm.close();
}
// does not work currently
/*
private void setDefaultTab(ViewPager viewPager) {
RealmResults<Facility> results = mRealm.where(Facility.class).equalTo("isFavorited", true)
.findAllAsync();
if(results.size() == 0)
viewPager.setCurrentItem(1);
else
viewPager.setCurrentItem(0);
}
*/
// Gets a Call from the given Retrofit service, then asynchronously executes it
// On success, copies the resulting facility list to the Realm DB
private void callWhatsOpenAPI(WhatsOpenService service) {
......
......@@ -4,13 +4,13 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import srct.whatsopen.ui.FacilityListFragment;
import srct.whatsopen.ui.fragments.FacilityListFragment;
public class FacilityListFragmentPagerAdapter extends FragmentPagerAdapter {
final int PAGE_COUNT = 4;
private String tabTitles[] = new String[] {"Fav", "All", "Open", "Closed"};
private String tabTitles[] = new String[] {"Favorites", "All", "Open", "Closed"};
public FacilityListFragmentPagerAdapter(FragmentManager fm) {
super(fm);
......
......@@ -67,7 +67,7 @@ public class FacilityListFragment extends android.support.v4.app.Fragment {
mRealm.where(Facility.class)
.findAllSortedAsync("isOpen", Sort.DESCENDING)));
break;
case "Fav":
case "Favorites":
mRecyclerView.setAdapter(new FacilityListAdapter(view.getContext(),
mRealm.where(Facility.class)
.equalTo("isFavorited", true)
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
android:state_selected="true"
android:drawable="@color/tabButtonPressed" />
<item android:state_enabled="true"
android:state_focused="true"
android:drawable="@color/tabButtonPressed" />
<item android:state_enabled="true"
android:state_pressed="true"
android:drawable="@color/tabButtonPressed" />
</selector>
</selector>
\ No newline at end of file
......@@ -12,6 +12,9 @@
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/tabs"
app:pstsShouldExpand="true"
app:pstsIndicatorColor="@color/colorPrimary"
app:pstsIndicatorHeight="6dp"
app:pstsTabBackground="@drawable/tab_button_bg"
android:layout_width="match_parent"
android:layout_height="48dp"/>
......
......@@ -10,7 +10,7 @@
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#FFFFFF"
tools:context="srct.whatsopen.ui.FacilityListFragment">
tools:context="srct.whatsopen.ui.fragments.FacilityListFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/rvFacilities"
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#006633</color>
<color name="colorPrimaryLight">#008542</color>
<color name="colorPrimaryDark">#015429</color>
<color name="colorAccent">#FF4081</color>
<color name="facilityText">#757575</color>
......@@ -8,4 +9,5 @@
<color name="favoriteButtonOn">#E8B827</color>
<color name="facilityClosed">#E0E0E0</color>
<color name="facilityOpen">#FAFAFA</color>
<color name="tabButtonPressed">#4b008542</color>
</resources>
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