-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Yotive
committed
Dec 31, 2016
1 parent
4158395
commit 7511156
Showing
14 changed files
with
494 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
conductor/src/main/java/com/example/myotive/conductor/ActionBarProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.example.myotive.conductor; | ||
|
||
import android.support.v7.app.ActionBar; | ||
|
||
/** | ||
* Created by michaelyotive_hr on 12/31/16. | ||
*/ | ||
|
||
public interface ActionBarProvider { | ||
ActionBar getSupportActionBar(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
conductor/src/main/java/com/example/myotive/conductor/ProgressBarProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.example.myotive.conductor; | ||
|
||
/** | ||
* Created by michaelyotive_hr on 12/31/16. | ||
*/ | ||
|
||
public interface ProgressBarProvider { | ||
void showProgressBar(); | ||
void hideProgressBar(); | ||
} |
56 changes: 56 additions & 0 deletions
56
...r/src/main/java/com/example/myotive/conductor/animation/ControllerTransistionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.example.myotive.conductor.animation; | ||
|
||
import android.animation.Animator; | ||
import android.animation.AnimatorSet; | ||
import android.animation.ObjectAnimator; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.animation.Animation; | ||
import android.view.animation.AnimationUtils; | ||
|
||
import com.bluelinelabs.conductor.changehandler.AnimatorChangeHandler; | ||
import com.example.myotive.conductor.R; | ||
|
||
/** | ||
* Created by michaelyotive_hr on 12/31/16. | ||
*/ | ||
|
||
public class ControllerTransistionHandler extends AnimatorChangeHandler { | ||
@NonNull | ||
@Override | ||
protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush, boolean toAddedToContainer) { | ||
//container.getContext().getResources().getAnimation(); | ||
Animation slideIn = AnimationUtils.loadAnimation(container.getContext(), R.anim.slide_in_right); | ||
Animation slideOut = AnimationUtils.loadAnimation(container.getContext(), R.anim.slide_out_right); | ||
|
||
if(isPush){ | ||
// to == enter | ||
if(to != null){ | ||
to.startAnimation(slideIn); | ||
} | ||
|
||
if(from != null){ | ||
from.startAnimation(slideOut); | ||
} | ||
} | ||
else{ | ||
// to == pop | ||
if(to != null){ | ||
to.startAnimation(slideOut); | ||
} | ||
|
||
if(from != null){ | ||
from.startAnimation(slideIn); | ||
} | ||
} | ||
|
||
return new AnimatorSet(); | ||
} | ||
|
||
@Override | ||
protected void resetFromView(@NonNull View from) { | ||
|
||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
conductor/src/main/java/com/example/myotive/conductor/controllers/BaseController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.example.myotive.conductor.controllers; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.v7.app.ActionBar; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import com.bluelinelabs.conductor.Controller; | ||
import com.example.myotive.conductor.ActionBarProvider; | ||
import com.example.myotive.conductor.ProgressBarProvider; | ||
|
||
/** | ||
* Created by michaelyotive_hr on 12/31/16. | ||
*/ | ||
|
||
public class BaseController extends Controller { | ||
|
||
public BaseController() { | ||
|
||
} | ||
|
||
public BaseController(Bundle bundle){ | ||
super(bundle); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) { | ||
return null; | ||
} | ||
|
||
private ActionBar getActionBar() { | ||
ActionBarProvider actionBarProvider = ((ActionBarProvider)getActivity()); | ||
return actionBarProvider != null ? actionBarProvider.getSupportActionBar() : null; | ||
} | ||
|
||
void setActionBarTitle(String title){ | ||
ActionBar actionBar = getActionBar(); | ||
if(actionBar != null){ | ||
actionBar.setTitle(title); | ||
} | ||
} | ||
|
||
void setDisplayHomeAsUpEnabled(boolean enabled){ | ||
ActionBar actionBar = getActionBar(); | ||
if(actionBar != null){ | ||
actionBar.setDisplayHomeAsUpEnabled(enabled); | ||
} | ||
} | ||
|
||
private ProgressBarProvider getProgressBarProvider(){ | ||
return ((ProgressBarProvider)getActivity()); | ||
} | ||
|
||
void showProgressBar(){ | ||
ProgressBarProvider progressBarProvider = getProgressBarProvider(); | ||
if(progressBarProvider != null){ | ||
progressBarProvider.showProgressBar(); | ||
} | ||
} | ||
|
||
void hideProgressBar(){ | ||
ProgressBarProvider progressBarProvider = getProgressBarProvider(); | ||
if(progressBarProvider != null){ | ||
progressBarProvider.hideProgressBar(); | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
...ctor/src/main/java/com/example/myotive/conductor/controllers/SpeakerDetailController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.example.myotive.conductor.controllers; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.text.TextUtils; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.example.myotive.codemash_common.network.models.Speaker; | ||
import com.example.myotive.codemash_common.ui.RoundedTransformation; | ||
import com.example.myotive.codemash_common.utility.ConversionUtility; | ||
import com.example.myotive.conductor.R; | ||
import com.squareup.picasso.Picasso; | ||
|
||
/** | ||
* Created by michaelyotive_hr on 12/30/16. | ||
*/ | ||
|
||
public class SpeakerDetailController extends BaseController { | ||
|
||
private Speaker speaker; | ||
private ImageView speakerImage; | ||
private TextView speakerBio; | ||
|
||
// Required constructor to restore instance state | ||
public SpeakerDetailController(Bundle args){ | ||
super(args); | ||
} | ||
|
||
|
||
// Constructor Injection allowed with Conductor as long as you have | ||
// default constructor | ||
public SpeakerDetailController(Speaker speaker){ | ||
this.speaker = speaker; | ||
} | ||
|
||
|
||
@NonNull | ||
@Override | ||
protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) { | ||
|
||
View view = inflater.inflate(R.layout.controller_speaker_detail, container, false); | ||
|
||
|
||
speakerImage = (ImageView)view.findViewById(R.id.detail_profile_image); | ||
if(!TextUtils.isEmpty(speaker.getGravatarUrl())){ | ||
|
||
String gravatarUrl = speaker.getGravatarUrl(); | ||
// As of 12/4, the gravatar URL is missing the protocol and that makes Picasso sad. | ||
if(!speaker.getGravatarUrl().contains("http")){ | ||
gravatarUrl = "http:" + speaker.getGravatarUrl(); | ||
} | ||
|
||
int speakerProfileSize = ConversionUtility.dpToPx(225, getActivity()); | ||
int radius = speakerProfileSize / 2; | ||
gravatarUrl = gravatarUrl + "?size=" + String.valueOf(speakerProfileSize); | ||
|
||
Picasso.with(getActivity()) | ||
.load(gravatarUrl) | ||
.transform(new RoundedTransformation(radius, 4)) | ||
.placeholder(com.example.myotive.codemash_common.R.drawable.codemash_gearhead) | ||
.into(speakerImage); | ||
} | ||
else{ | ||
Picasso.with(getActivity()) | ||
.load(com.example.myotive.codemash_common.R.drawable.codemash_gearhead) | ||
.into(speakerImage); | ||
} | ||
|
||
speakerBio = (TextView)view.findViewById(R.id.detail_profile_bio); | ||
speakerBio.setText(speaker.getBiography()); | ||
|
||
return view; | ||
} | ||
|
||
@Override | ||
protected void onAttach(@NonNull View view) { | ||
super.onAttach(view); | ||
setActionBarTitle(speaker.getFullName()); | ||
setDisplayHomeAsUpEnabled(true); | ||
} | ||
|
||
@Override | ||
public boolean handleBack() { | ||
return super.handleBack(); | ||
} | ||
} |
Oops, something went wrong.