Skip to content

Commit

Permalink
why the fuck would you make a new class
Browse files Browse the repository at this point in the history
  when you could just extend in runtime,

  and also in the process it fucks up with the goToUploadFragment functionality. le duh

Signed-off-by: Arnav Gupta <[email protected]>
  • Loading branch information
championswimmer committed Apr 26, 2015
1 parent 02692f4 commit cc123fe
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 43 deletions.
53 changes: 14 additions & 39 deletions app/src/main/java/in/tosc/studddin/fragments/NotesFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class NotesFragment extends Fragment {
FragmentStatePagerAdapter fragmentPagerAdapter;
int p,s;
NotesUploadFragment notesUploadFragment;
ViewPagerAdapter adapter;
SlidingTabLayout tabs;


Expand All @@ -54,7 +53,18 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
s = getActivity().getResources().getColor(R.color.colorPrimaryDark);
ApplicationWrapper.setCustomTheme((ActionBarActivity) getActivity(),p,s);

/* fragmentPagerAdapter = new FragmentStatePagerAdapter(getChildFragmentManager()) {
fragmentPagerAdapter = new FragmentStatePagerAdapter(getChildFragmentManager()) {

String[] fragmentTitles = new String[] {
getResources().getString(R.string.notes_fragment_title_search),
getResources().getString(R.string.notes_fragment_title_upload)
};

@Override
public CharSequence getPageTitle(int position) {
return fragmentTitles[position];
}

@Override
public Fragment getItem(int position) {
switch (position) {
Expand All @@ -72,11 +82,10 @@ public int getCount() {
return 2;
}

};*/
};

notesPager = (ViewPager) rootView.findViewById(R.id.notes_pager);
adapter = new ViewPagerAdapter(getActivity().getSupportFragmentManager());
notesPager.setAdapter(adapter);
notesPager.setAdapter(fragmentPagerAdapter);
tabs = (SlidingTabLayout) rootView.findViewById(R.id.tabs);
tabs.setDistributeEvenly(true);
tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
Expand Down Expand Up @@ -110,39 +119,5 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
notesUploadFragment.setImagePaths(paths, true);

}

public class ViewPagerAdapter extends FragmentStatePagerAdapter {

CharSequence TAB_TITLES[]={"Notes","Upload Notes"};
int NUM_TAB =2;

public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}

@Override
public Fragment getItem(int position) {


if(position == 0)
{
return (new NotesSearchFragment());
}
else {
return (new NotesUploadFragment());
}

}

@Override
public CharSequence getPageTitle(int position) {
return TAB_TITLES[position];
}

@Override
public int getCount() {
return NUM_TAB;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void done(byte[] bytes, ParseException e) {
public void onClick(View v) {
NotesCustomDialog notesCustomDialog = new NotesCustomDialog(mContext,
notesCollegeName, notesBranchName, notesTopicName, notesSubjectName, position, uploadedBy);
notesCustomDialog.setTitle(mContext.getString(R.string.notes_details));
notesCustomDialog.setTitle(mContext.getString(R.string.listings_details));
notesCustomDialog.show();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
Expand All @@ -28,6 +29,7 @@
import java.util.ArrayList;
import java.util.List;

import in.tosc.studddin.ApplicationWrapper;
import in.tosc.studddin.R;
import in.tosc.studddin.fragments.NotesFragment;
import in.tosc.studddin.ui.FloatingActionButton;
Expand All @@ -41,6 +43,8 @@
*/
public class NotesSearchFragment extends Fragment {

public static final String TAG = "NotesSearch";

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
Expand Down Expand Up @@ -177,6 +181,7 @@ public void onClick(View v) {


public void goToUploadFragment() {
if (ApplicationWrapper.LOG_DEBUG) Log.d(TAG, "goToUploadFragment called");
NotesFragment notesFragment = (NotesFragment) getParentFragment();
if (notesFragment != null) {
notesFragment.goToOtherFragment(1);
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@

<!-- Listings -->
<string name="upload_complete">Upload complete</string>
<string name="notes_uploading">Uploading</string>
<string name="notes_downloading">Downloading...</string>
<string name="notes_details">Details:</string>
<string name="listings_uploading">Uploading</string>
<string name="listings_downloading">Downloading...</string>
<string name="listings_details">Details:</string>
<string name="dialog_download_starting">Download Start</string>
<string name="placeholder_dialog_listing">You haven\'t posted an item to sell yet!</string>
<string name="lets_get_going">lets get going</string>

<!-- Notes -->
<string name="notes_fragment_title_search">Get Notes</string>
<string name="notes_fragment_title_upload">Upload Notes</string>

</resources>

0 comments on commit cc123fe

Please sign in to comment.