Skip to content

Commit

Permalink
Merge pull request #12 from johntzan/bottom_nav
Browse files Browse the repository at this point in the history
-Past Weekend Leagues and games
  • Loading branch information
John Tzanidakis committed Feb 18, 2017
2 parents b9abeab + 7c8f1b4 commit 5c2f971
Show file tree
Hide file tree
Showing 19 changed files with 1,731 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ android {
signingConfig signingConfigs.release
proguardFile 'proguard-rules.pro'
targetSdkVersion 25
versionCode 6
versionName '1.2.1'
versionCode 7
versionName '1.3'
resValue "string", "app_name", "FUT Weekend League Stats"
}
staging {
Expand All @@ -66,7 +66,7 @@ android {
proguardFile 'proguard-rules.pro'
targetSdkVersion 25
versionCode 1
versionName '1.2.1'
versionName '1.3'
resValue "string", "app_name", "FUT Weekend League Stats"
}
}
Expand All @@ -85,18 +85,18 @@ dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
transitive = true;
}
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.jaredrummler:material-spinner:1.1.0'
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.github.githubwing:ByeBurger:1.2.3'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5'
testCompile 'junit:junit:4.12'
}
5 changes: 5 additions & 0 deletions app/src/main/java/com/futchampionsstats/Utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public class Constants {
public static final String SAVED_SQUADS = "saved_squads";
public static final String EDIT_SQUAD = "edit_squad";
public static final String EDIT_SQUAD_INDEX = "edit_squad_index";
public static final String VIEW_PAST_WLS = "view_past_wls";
public static final String VIEW_WL = "view_wl";
public static final String VIEW_WL_POS = "view_wl_pos";
public static final String VIEW_PAST_WL_GAMES = "view_past_wl_games";
public static final String VIEW_PAST_WL_GAME = "view_past_wl_game";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
package com.futchampionsstats.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.futchampionsstats.R;
import com.futchampionsstats.models.Game;
import com.futchampionsstats.models.WeekendLeague;
import com.google.gson.Gson;

import java.util.ArrayList;


/**
* Created by yiannitzan on 2/17/17.
*/

public class PastWlsListAdapter extends RecyclerView.Adapter<PastWlsListAdapter.ViewHolder> {

private static final String TAG = GamesListAdapter.class.getSimpleName();
private ArrayList<WeekendLeague> data;
private Context context;
private LayoutInflater mInflater; // Stores the layout inflater

public PastWlsListAdapter(Context c, ArrayList<WeekendLeague> d) {
context = c;
data = d;
// Stores inflater for use later
if (context != null) mInflater = LayoutInflater.from(context);
}

@Override
public int getItemCount() {
return data != null ? data.size() : 0;
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public PastWlsListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// create a new view
context = parent.getContext();
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.past_wls_layout, parent, false);
// set the view's size, margins, paddings and layout parameters
PastWlsListAdapter.ViewHolder vh = new PastWlsListAdapter.ViewHolder(v);
return vh;
}

@Override
public void onBindViewHolder(final PastWlsListAdapter.ViewHolder holder, final int position) {
if (data.get(position).getClass() == WeekendLeague.class) {
WeekendLeague item = data.get(position);
Log.d(TAG, "onBindViewHolder: " + new Gson().toJson(item));
if(item!=null && item.getWeekendLeague()!=null){
holder.wl_date.setText(item.getDateOfWL());
holder.games_played.setText(WeekendLeague.getTotalGamesPlayed(item));
holder.games_won.setText(WeekendLeague.getWinTotal(item));
holder.total_gs.setText(WeekendLeague.getTotalGoals(item)[0]);
holder.total_gc.setText(WeekendLeague.getTotalGoals(item)[1]);
holder.g_ratio.setText(WeekendLeague.getAvgGoalPerShotString(item));

}


}

}

public class ViewHolder extends RecyclerView.ViewHolder {
TextView wl_date;
TextView games_played;
TextView games_won;
TextView total_gs;
TextView total_gc;
TextView g_ratio;

Context ctx;

public ViewHolder(View v) {
super(v);

wl_date = (TextView) v.findViewById(R.id.past_wl_date);
games_played = (TextView) v.findViewById(R.id.past_wl_gp);
games_won = (TextView) v.findViewById(R.id.past_wl_gw);
total_gs = (TextView) v.findViewById(R.id.past_wl_total_gs);
total_gc = (TextView) v.findViewById(R.id.past_wl_total_gc);
g_ratio = (TextView) v.findViewById(R.id.past_wl_g_ratio);

ctx = v.getContext();

}

}

public interface PastWlsListAdapterListener {
public void onPastWlItemClick(int position, Game item);
}
public static class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
GestureDetector mGestureDetector;
private PastWlsListAdapter.RecyclerItemClickListener.OnItemClickListener mListener;

public RecyclerItemClickListener(Context context, PastWlsListAdapter.RecyclerItemClickListener.OnItemClickListener listener) {
mListener = listener;
mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
});
}

@Override
public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
View childView = view.findChildViewUnder(e.getX(), e.getY());
if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) {
mListener.onItemClick(childView, view.getChildAdapterPosition(childView));
}
return false;
}

@Override
public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
}

@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

}

public interface OnItemClickListener {
void onItemClick(View view, int position);
}
}
}
79 changes: 76 additions & 3 deletions app/src/main/java/com/futchampionsstats/main/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
public class MainActivity extends AppCompatActivity implements MainActivityFragment.OnMainFragmentInteractionListener,
WLFragment.OnNewWLFragmentInteractionListener, NewGameFragment.OnNewGameFragmentInteractionListener,
ViewGamesFragment.OnViewGamesFragmentInteractionListener, EditGameFragment.OnEditGameFragmentInteractionListener,
PastWLFragment.OnPastWLFragmentInteractionListener, MySquadsFragment.OnMySquadsFragmentInteractionListener
PastWLFragment.OnPastWLFragmentInteractionListener, MySquadsFragment.OnMySquadsFragmentInteractionListener,
ViewPastWLsFragment.OnViewPastWLsFragmentInteractionListener, ViewPastWLGamesFragment.OnViewPastWLGamesFragmentInteractionListener,
PastWLViewGameFragment.OnPastWLViewGameFragmentInteractionListener
{

public static final String TAG = MainActivity.class.getSimpleName();
Expand All @@ -62,6 +64,9 @@ public class MainActivity extends AppCompatActivity implements MainActivityFragm
private EditGameFragment editGameFragment;
private PastWLFragment pastWLFragment;
private MySquadsFragment mySquadsFragment;
private ViewPastWLsFragment viewPastWLsFragment;
private ViewPastWLGamesFragment viewPastWLGamesFragment;
private PastWLViewGameFragment pastWLViewGameFragment;

private WeekendLeague weekendLeague;

Expand Down Expand Up @@ -115,6 +120,9 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
editGameFragment = new EditGameFragment();
pastWLFragment = new PastWLFragment();
mySquadsFragment = new MySquadsFragment();
viewPastWLsFragment = new ViewPastWLsFragment();
viewPastWLGamesFragment = new ViewPastWLGamesFragment();
pastWLViewGameFragment = new PastWLViewGameFragment();
}

selectFragment(selectedItem);
Expand Down Expand Up @@ -618,6 +626,13 @@ public void onClick(SweetAlertDialog sweetAlertDialog) {
pDialog.setCanceledOnTouchOutside(true);
pDialog.show();
}

if(args.containsKey(Constants.VIEW_PAST_WLS)){

viewPastWLsFragment = new ViewPastWLsFragment();
displayFragment(viewPastWLsFragment, "view_past_wls");

}
}
}

Expand Down Expand Up @@ -780,6 +795,53 @@ public void onClick(View view) {
}
}

@Override
public void onViewPastWLsFragmentInteraction(Bundle args) {
if(args!=null){
if(args.containsKey(Constants.BACK_BTN)){
onBackPressed();
}
if(args.containsKey(Constants.VIEW_WL)){
WeekendLeague weekendLeague = (WeekendLeague) args.getSerializable(Constants.VIEW_WL);
Bundle b = new Bundle();
b.putSerializable(Constants.VIEW_PAST_WL_GAMES, weekendLeague);
viewPastWLGamesFragment = new ViewPastWLGamesFragment();
viewPastWLGamesFragment.setArguments(b);
displayFragment(viewPastWLGamesFragment, "view_past_wl_games");

}

}
}

@Override
public void onViewPastWLGamesFragmentInteraction(Bundle args) {
if(args!=null){
if(args.containsKey(Constants.BACK_BTN)){
onBackPressed();
}
if(args.containsKey(Constants.VIEW_PAST_WL_GAME)){
Game game = (Game) args.getSerializable(Constants.VIEW_PAST_WL_GAME);

Bundle b = new Bundle();
b.putSerializable(Constants.VIEW_PAST_WL_GAME, game);
pastWLViewGameFragment = new PastWLViewGameFragment();
pastWLViewGameFragment.setArguments(b);
displayFragment(pastWLViewGameFragment, "view_past_wl_game");

}
}
}

@Override
public void onPastWLViewGameFragmentInteraction(Bundle args) {
if(args!=null){
if(args.containsKey(Constants.BACK_BTN)){
onBackPressed();
}
}
}

@Override
protected void onResume() {
super.onResume();
Expand All @@ -800,10 +862,21 @@ public void onBackPressed() {
else{
MenuItem homeItem = mBottomNav.getMenu().getItem(1);
if (mSelectedItem != homeItem.getItemId()) {
Log.d(TAG, "onBackPressed: selectedItem!=homeItem");
// select home item
super.onBackPressed();
selectFragment(homeItem);

if((pastWLFragment!=null && pastWLFragment.isVisible()) ||
mySquadsFragment!=null && mySquadsFragment.isVisible()){
Log.d(TAG, "onBackPressed: pastWl || my squads is visible");
super.onBackPressed();
selectFragment(homeItem);
}
else{
Log.d(TAG, "onBackPressed: not pastWl || mysquads");
super.onBackPressed();
}
} else {
Log.d(TAG, "onBackPressed: selectedItem == homeItem");
super.onBackPressed();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ public void onResume() {

setupAdapter();
}
else{
mySquads = new ArrayList<Squad>();
setupAdapter();
}

}

Expand Down
Loading

0 comments on commit 5c2f971

Please sign in to comment.