Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 17 files changed
  • 0 commit comments
  • 2 contributors
Commits on Apr 18, 2012
@popasquat89 popasquat89 RateBar implementation with viewpager a5bafcb
Commits on Apr 20, 2012
@dariusriggins Merge pull request #2 from dariusriggins/RCViews
RateBar implementation with viewpager
9d7fa9c
View
12 Brink/AndroidManifest.xml
@@ -102,7 +102,7 @@
</intent-filter>
</activity>
- <activity android:name=".ViewHandler"
+ <activity android:name=".Activities.ViewHandler"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
@@ -131,6 +131,16 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
+ <activity android:name=".Rate"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.Black.NoTitleBar">
+ <intent-filter>
+ <action
+ android:name="com.brink.main.Activities.Rate" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
</application>
View
2 Brink/project.properties
@@ -8,5 +8,5 @@
# project structure.
# Project target.
-target=android-10
+target=android-15
android.library.reference.1=../../facebook-android-sdk/facebook
View
33 Brink/res/layout/mainpage.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TabHost
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/tabhost"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TabWidget
+ android:id="@android:id/tabs"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"/>
+
+ <FrameLayout
+ android:id="@android:id/tabcontent"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_weight="0"/>
+
+ <android.support.v4.view.ViewPager
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
+
+ </LinearLayout>
+</TabHost>
View
7 Brink/src/com/brink/main/Activities/Loading.java
@@ -0,0 +1,7 @@
+package com.brink.main.Activities;
+
+import android.app.Activity;
+
+public class Loading extends Activity{
+
+}
View
7 Brink/src/com/brink/main/Activities/Login.java
@@ -0,0 +1,7 @@
+package com.brink.main.Activities;
+
+import android.app.Activity;
+
+public class Login extends Activity {
+
+}
View
7 Brink/src/com/brink/main/Activities/Register.java
@@ -0,0 +1,7 @@
+package com.brink.main.Activities;
+
+import android.app.Activity;
+
+public class Register extends Activity {
+
+}
View
7 Brink/src/com/brink/main/Activities/Switch.java
@@ -0,0 +1,7 @@
+package com.brink.main.Activities;
+
+import android.app.Activity;
+
+public class Switch extends Activity {
+
+}
View
150 Brink/src/com/brink/main/Activities/ViewHandler.java
@@ -0,0 +1,150 @@
+package com.brink.main.Activities;
+
+import java.util.ArrayList;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TabHost;
+import android.widget.TabWidget;
+
+import com.brink.main.R;
+import com.brink.main.Fragments.Bars;
+import com.brink.main.Fragments.Rate;
+
+public class ViewHandler extends FragmentActivity{
+ TabHost mTabHost;
+ ViewPager mViewPager;
+ TabsAdapter mTabsAdapter;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.mainpage);
+ mTabHost = (TabHost)findViewById(android.R.id.tabhost);
+ mTabHost.setup();
+
+ mViewPager = (ViewPager)findViewById(R.id.pager);
+
+ mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);
+
+ mTabsAdapter.addTab(mTabHost.newTabSpec("rate").setIndicator("Rate Bar"),
+ Rate.RateFragment.class , null);
+ mTabsAdapter.addTab(mTabHost.newTabSpec("bars").setIndicator("Bars"),
+ Bars.BarsFragment.class, null);
+// mTabsAdapter.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
+// LoaderCustomSupport.AppListFragment.class, null);
+// mTabsAdapter.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
+// LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
+
+ if (savedInstanceState != null) {
+ mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
+ }
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putString("tab", mTabHost.getCurrentTabTag());
+ }
+
+
+ public static class TabsAdapter extends FragmentPagerAdapter
+ implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener {
+ private final Context mContext;
+ private final TabHost mTabHost;
+ private final ViewPager mViewPager;
+ private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
+
+ static final class TabInfo {
+ private final String tag;
+ private final Class<?> clss;
+ private final Bundle args;
+
+ TabInfo(String _tag, Class<?> _class, Bundle _args) {
+ tag = _tag;
+ clss = _class;
+ args = _args;
+ }
+ }
+
+ static class DummyTabFactory implements TabHost.TabContentFactory {
+ private final Context mContext;
+
+ public DummyTabFactory(Context context) {
+ mContext = context;
+ }
+
+
+ public View createTabContent(String tag) {
+ View v = new View(mContext);
+ v.setMinimumWidth(0);
+ v.setMinimumHeight(0);
+ return v;
+ }
+ }
+
+ public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager pager) {
+ super(activity.getSupportFragmentManager());
+ mContext = activity;
+ mTabHost = tabHost;
+ mViewPager = pager;
+ mTabHost.setOnTabChangedListener(this);
+ mViewPager.setAdapter(this);
+ mViewPager.setOnPageChangeListener(this);
+ }
+
+ public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
+ tabSpec.setContent(new DummyTabFactory(mContext));
+ String tag = tabSpec.getTag();
+
+ TabInfo info = new TabInfo(tag, clss, args);
+ mTabs.add(info);
+ mTabHost.addTab(tabSpec);
+ notifyDataSetChanged();
+ }
+
+
+ public int getCount() {
+ return mTabs.size();
+ }
+
+
+ public Fragment getItem(int position) {
+ TabInfo info = mTabs.get(position);
+ return Fragment.instantiate(mContext, info.clss.getName(), info.args);
+ }
+
+ public void onTabChanged(String tabId) {
+ int position = mTabHost.getCurrentTab();
+ mViewPager.setCurrentItem(position);
+ }
+
+
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ }
+
+
+ public void onPageSelected(int position) {
+ // Unfortunately when TabHost changes the current tab, it kindly
+ // also takes care of putting focus on it when not in touch mode.
+ // The jerk.
+ // This hack tries to prevent this from pulling focus out of our
+ // ViewPager.
+ TabWidget widget = mTabHost.getTabWidget();
+ int oldFocusability = widget.getDescendantFocusability();
+ widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
+ mTabHost.setCurrentTab(position);
+ widget.setDescendantFocusability(oldFocusability);
+ }
+
+ public void onPageScrollStateChanged(int state) {
+ }
+ }
+}
View
7 Brink/src/com/brink/main/Fragments/ActivityFeed.java
@@ -0,0 +1,7 @@
+package com.brink.main.Fragments;
+
+import android.support.v4.app.Fragment;
+
+public class ActivityFeed extends Fragment {
+
+}
View
7 Brink/src/com/brink/main/Fragments/BarPage.java
@@ -0,0 +1,7 @@
+package com.brink.main.Fragments;
+
+import android.support.v4.app.Fragment;
+
+public class BarPage extends Fragment{
+
+}
View
37 Brink/src/com/brink/main/Fragments/Bars.java
@@ -0,0 +1,37 @@
+package com.brink.main.Fragments;
+
+import com.brink.main.R;
+import com.brink.main.Fragments.Rate.RateFragment;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class Bars extends FragmentActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ FragmentManager fm = getSupportFragmentManager();
+ if(fm.findFragmentById(android.R.id.content) == null)
+ {
+ RateFragment mRateFragment = new RateFragment();
+ fm.beginTransaction().add(android.R.id.content, mRateFragment).commit();
+ }
+ }
+
+ public static class BarsFragment extends Fragment
+ {
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.ratedbarspage, container, false);
+ }
+ }
+}
View
333 Brink/src/com/brink/main/Fragments/Rate.java
@@ -0,0 +1,333 @@
+package com.brink.main.Fragments;
+
+import java.util.ArrayList;
+
+import android.content.Context;
+import android.content.Intent;
+import android.database.DataSetObserver;
+import android.graphics.Color;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.SeekBar;
+import android.widget.Spinner;
+import android.widget.SpinnerAdapter;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+
+import com.brink.main.IncomingAPI;
+import com.brink.main.OutgoingAPI;
+import com.brink.main.R;
+import com.brink.main.Stored;
+
+
+public class Rate extends FragmentActivity{
+
+ static Spinner s1;
+ static SeekBar seekbar;
+ static ImageButton DoneButton;
+ static ImageButton CancelButton;
+
+ public static ImageButton button;
+ public static ImageView image;
+ private static final int ACTION_TAKE_PHOTO_B = 1;
+ private static final int ACTION_TAKE_PHOTO_S = 2;
+
+ private static final String JPEG_FILE_PREFIX = "IMG_";
+ private static final String JPEG_FILE_SUFFIX = ".jpg";
+
+ private String mCurrentPhotoPath;
+
+ public static Context _Context;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ FragmentManager fm = getSupportFragmentManager();
+ if(fm.findFragmentById(android.R.id.content) == null)
+ {
+ RateFragment mRateFragment = new RateFragment();
+ fm.beginTransaction().add(android.R.id.content, mRateFragment).commit();
+
+
+ }
+ }
+ public static class RateFragment extends Fragment
+ {
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.barpopuprate, container, false);
+ }
+
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+
+ //Get a Handle on all the individual XML Objects
+ DoneButton = (ImageButton) this.getView().findViewById(R.id.donebutton);
+ CancelButton = (ImageButton) this.getView().findViewById(R.id.cancelbutton);
+ image = ( ImageView ) this.getView().findViewById( R.id.picturetaken );
+ button = (ImageButton ) this.getView().findViewById( R.id.addphoto );
+ s1 = (Spinner) this.getView().findViewById(R.id.dropdownbars);
+ final TextView value = (TextView) this.getView().findViewById(R.id.ratingvalue);
+ seekbar = (SeekBar) this.getView().findViewById(R.id.ratingseek);
+ image.setVisibility(View.INVISIBLE);
+
+ setRetainInstance(true);
+
+ _Context = getActivity();
+ final Rate mRate = new Rate();
+ RetrieveBarsTask getBars = mRate.new RetrieveBarsTask(this);
+ getBars.execute(Stored.UserInformation.retrieveUsersCity());
+
+
+ button.setOnClickListener(new View.OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ //TODO add the ability to capture large images then scale them down rather than small images
+ Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
+ //intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
+
+
+ startActivityForResult(intent, ACTION_TAKE_PHOTO_S);
+
+ }
+ });
+
+
+ //For the SeekBar
+ seekbar.setMax(5);
+
+ seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
+ {
+ public void onProgressChanged(
+ SeekBar seekBar,
+ int progress,
+ boolean fromUser)
+ {
+
+ Stored.ratingPicked = progress;
+ value.setText("" + progress);
+
+ }
+
+ public void onStartTrackingTouch(SeekBar seekBar)
+ {
+ // TODO Auto-generated method stub
+ }
+
+ public void onStopTrackingTouch(SeekBar seekBar)
+ {
+ //Error Check so if the user Clicks Done we make sure we have a value.
+ if(Stored.ratingPicked != 0)
+ {
+ Stored.ratingCorrect = true;
+ }
+ else
+ {
+ Stored.ratingCorrect = false;
+ }
+ }
+ });
+ DoneButton.setOnClickListener(new View.OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ if(Stored.ratingCorrect == true)
+ {
+ if(Stored.pictureTaken != null && Stored.uploadToFacebook == false)
+ {
+ //Launch 2 tasks, Upload picture to our server pool, Upload Rating to server.
+ Log.w("Launching 2 Tasks for Rating, and Server Upload", "RateBar.java");
+ SendBarRatingTask sendRating = mRate.new SendBarRatingTask();
+ sendRating.execute(Stored.ratingPicked);
+ }
+ else if(Stored.pictureTaken != null && Stored.uploadToFacebook == true)
+ {
+ //Launch 3 tasks, Upload picture to facebook, Upload picture to our server pool, Upload Rating to server.
+ Log.w("Launching 3 tasks for Rating, Facebook Upload, and Server Upload", "RateBar.Java");
+ }
+ else
+ {
+ //Launch 1 task for Uploading rating to the server.
+ Log.w("Launching 1 tasks for Rating", "RateBar.Java");
+ SendBarRatingTask sendRating = mRate.new SendBarRatingTask();
+ sendRating.execute(Stored.ratingPicked);
+ }
+ }
+
+ }
+ });
+ CancelButton.setOnClickListener(new View.OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ Log.w("User Has called Cancel button", "Closing out RateBar Activity");
+
+ }
+ });
+
+
+
+ }
+ }
+
+ /*
+ * Description: BarsSpinnerAdapter is a Custom adapter for the spinner on the RateBar page.
+ */
+ private class BarsSpinnerAdapter implements SpinnerAdapter
+ {
+
+
+ ArrayList<Stored.BarList> data;
+
+
+ public BarsSpinnerAdapter(ArrayList<Stored.BarList> data){
+ this.data = data;
+ }
+
+ public int getCount() {
+ return data.size();
+ }
+
+ public Object getItem(int position) {
+
+ return data.get(position);
+ }
+
+ public long getItemId(int position) {
+
+ return position;
+ }
+
+ public int getItemViewType(int position) {
+ return android.R.layout.simple_spinner_dropdown_item;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ TextView v = new TextView(_Context);
+ v.setTextColor(Color.BLACK);
+ v.setText(data.get(position).retrieveBarsName());
+ return v;
+
+
+ }
+
+ public int getViewTypeCount() {
+ return 1;
+ }
+
+ public boolean hasStableIds() {
+ return false;
+ }
+
+ public boolean isEmpty() {
+ return false;
+ }
+
+ public void registerDataSetObserver(DataSetObserver arg0) {
+
+ }
+
+ public void unregisterDataSetObserver(DataSetObserver arg0) {
+
+ }
+
+ public View getDropDownView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null)
+ {
+ LayoutInflater vi = (LayoutInflater) _Context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ convertView = vi.inflate(android.R.layout.simple_spinner_dropdown_item, null);
+ }
+
+ TextView textView = (TextView) convertView.findViewById(android.R.id.text1);
+ textView.setText(data.get(position).retrieveBarsName());
+
+ return convertView;
+
+ }
+
+ }
+ private class RetrieveBarsTask extends AsyncTask<String, Integer, ArrayList<Stored.BarList>>
+ {
+ private RateFragment _page;
+
+ protected RetrieveBarsTask(RateFragment page)
+ {
+ _page = page;
+ }
+ protected ArrayList<Stored.BarList> doInBackground(String... params)
+ {
+ return IncomingAPI.populateBarPick("TigerLand");
+ }
+
+ protected void onPostExecute(ArrayList<Stored.BarList> result)
+ {
+
+
+ BarsSpinnerAdapter adapter = new BarsSpinnerAdapter(result);
+
+ s1.setAdapter(adapter);
+
+ s1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
+ {
+ public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
+ {
+ Stored.BarList b = (Stored.BarList) parent.getItemAtPosition(pos);
+ Toast.makeText(_Context, "You have selected item : " + b.retrieveBarsName(), Toast.LENGTH_SHORT).show();
+ Stored.barToCheckIn = b.retrieveBarsName();
+ Log.w("BAR SELECTED FOR CHECK", Stored.barToCheckIn);
+
+ }
+
+ public void onNothingSelected(AdapterView parent) {}
+ });
+
+ }
+ }
+
+ private class SendBarRatingTask extends AsyncTask<Integer, Void, Boolean>
+ {
+
+ //doInBackground should make the network call to send the Rating to our server
+ @Override
+ protected Boolean doInBackground(Integer... params)
+ {
+
+ return OutgoingAPI.SendBarRating(params[0], Stored.barToCheckIn);
+ }
+
+ //onPostExecute should be sent confirmation via a Boolean that the rating was sent successfully to the server.
+ @Override
+ protected void onPostExecute(Boolean result)
+ {
+ if(result)
+ {
+ Toast.makeText(_Context, "Rating Has Been Sent Successfully", Toast.LENGTH_LONG).show();
+ Log.w("Rating was sent Successfully", "SendBarRatingTask - RateBar.java");
+ finish();
+ }
+ else
+ {
+ Toast.makeText(_Context, "Problem sending Bar Rating", Toast.LENGTH_LONG).show();
+ Log.w("Problem Sending Bar Rating", "SendBarRatingTask - RateBar.java");
+ }
+
+ }
+
+ }
+}
View
7 Brink/src/com/brink/main/Fragments/Settings.java
@@ -0,0 +1,7 @@
+package com.brink.main.Fragments;
+
+import android.support.v4.app.Fragment;
+
+public class Settings extends Fragment{
+
+}
View
7 Brink/src/com/brink/main/Fragments/TopBars.java
@@ -0,0 +1,7 @@
+package com.brink.main.Fragments;
+
+import android.support.v4.app.Fragment;
+
+public class TopBars extends Fragment{
+
+}
View
2 Brink/src/com/brink/main/HomePage.java
@@ -101,7 +101,7 @@ public void onItemClick(AdapterView<?> parent, View v, int position, long id)
Toast.makeText(HomePage.this, bar , Toast.LENGTH_SHORT).show();
- //startActivity(new Intent("com.brink.ViewHandler"));
+ startActivity(new Intent("com.brink.ViewHandler"));
//finish();
break;
}
View
2 Brink/src/com/brink/main/RateBar.java
@@ -52,6 +52,8 @@
private static final String JPEG_FILE_SUFFIX = ".jpg";
private String mCurrentPhotoPath;
+
+
View
69 Brink/src/com/brink/main/ViewHandler.java
@@ -1,69 +0,0 @@
-package com.brink.main;
-
-import android.app.Activity;
-import android.graphics.Bitmap;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.util.Log;
-import android.widget.ImageView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-public class ViewHandler extends Activity{
-
- ProgressBar avatarLoad;
- ImageView userAvatar;
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- //Initiate the View
- setContentView(R.layout.homeview);
-
- //Get a Handle on all items.
- TextView usersName = (TextView) findViewById(R.id.usersNameView);
- TextView usersLocation = (TextView) findViewById(R.id.usersLocationView);
- avatarLoad = (ProgressBar) findViewById(R.id.progressLogoLoadView);
- userAvatar = (ImageView) findViewById(R.id.userLogoView);
-
-
- if(Stored.FbLoginType)
- {
- new RetrieveFacebookInfoTask().execute(Stored.UserInformation.retrieveUsersPictureURL());
- usersName.setText(Stored.UserInformation.retrieveUsersName());
-
- }
- else if(Stored.AppLoginType)
- {
- usersName.setText(Stored.UserInformation.retrieveUsersName());
- }
-
- }
-
- @Override
- public void onStart()
- {
- super.onStart();
- Log.w("Exitting Clean", "true");
- }
-
-
- private class RetrieveFacebookInfoTask extends AsyncTask<String, Void, Bitmap>
- {
-
- protected Bitmap doInBackground(String... params) {
-
- return IncomingAPI.RetrieveFacebookAvatar();
- }
-
- protected void onPostExecute(Bitmap result)
- {
- userAvatar.setImageBitmap(result);
- avatarLoad.setVisibility(4);
- }
-
- }
-
-}

No commit comments for this range

Something went wrong with that request. Please try again.