Skip to content

Commit

Permalink
Butter Knife 7.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Jul 14, 2015
1 parent 224a931 commit e3df2d4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion telecine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ android {
dependencies {
compile 'com.android.support:support-annotations:22.2.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.jakewharton.timber:timber:3.1.0'
compile 'com.bugsnag:bugsnag-android:3.2.5'
compile 'com.squareup.dagger:dagger:1.2.2'
Expand Down
25 changes: 13 additions & 12 deletions telecine/src/main/java/com/jakewharton/telecine/OverlayView.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.BindDimen;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import java.util.Locale;

Expand Down Expand Up @@ -80,29 +81,29 @@ interface Listener {
void onStop();
}

@InjectView(R.id.record_overlay_buttons) View buttonsView;
@InjectView(R.id.record_overlay_cancel) View cancelView;
@InjectView(R.id.record_overlay_start) View startView;
@InjectView(R.id.record_overlay_stop) View stopView;
@InjectView(R.id.record_overlay_recording) TextView recordingView;
@Bind(R.id.record_overlay_buttons) View buttonsView;
@Bind(R.id.record_overlay_cancel) View cancelView;
@Bind(R.id.record_overlay_start) View startView;
@Bind(R.id.record_overlay_stop) View stopView;
@Bind(R.id.record_overlay_recording) TextView recordingView;

@BindDimen(R.dimen.overlay_width) int animationWidth;

private final Listener listener;
private final boolean showCountDown;
private final int animationWidth;

private OverlayView(Context context, Listener listener, boolean showCountDown) {
super(context);
this.listener = listener;
this.showCountDown = showCountDown;

int width = getResources().getDimensionPixelSize(R.dimen.overlay_width);
inflate(context, R.layout.overlay_view, this);
ButterKnife.bind(this);

if (getLayoutDirectionFromLocale(Locale.getDefault()) == LAYOUT_DIRECTION_RTL) {
width = -width; // Account for animating in from the other side of the screen.
animationWidth = -animationWidth; // Account for animating in from the other side of screen.
}
animationWidth = width;

inflate(context, R.layout.overlay_view, this);
ButterKnife.inject(this);
CheatSheet.setup(cancelView);
CheatSheet.setup(startView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import android.os.Bundle;
import android.widget.Spinner;
import android.widget.Switch;
import butterknife.Bind;
import butterknife.BindColor;
import butterknife.BindString;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnCheckedChanged;
import butterknife.OnClick;
import butterknife.OnItemSelected;
Expand All @@ -20,11 +22,14 @@
import timber.log.Timber;

public final class TelecineActivity extends Activity {
@InjectView(R.id.spinner_video_size_percentage) Spinner videoSizePercentageView;
@InjectView(R.id.switch_show_countdown) Switch showCountdownView;
@InjectView(R.id.switch_hide_from_recents) Switch hideFromRecentsView;
@InjectView(R.id.switch_recording_notification) Switch recordingNotificationView;
@InjectView(R.id.switch_show_touches) Switch showTouchesView;
@Bind(R.id.spinner_video_size_percentage) Spinner videoSizePercentageView;
@Bind(R.id.switch_show_countdown) Switch showCountdownView;
@Bind(R.id.switch_hide_from_recents) Switch hideFromRecentsView;
@Bind(R.id.switch_recording_notification) Switch recordingNotificationView;
@Bind(R.id.switch_show_touches) Switch showTouchesView;

@BindString(R.string.app_name) String appName;
@BindColor(R.color.primary_normal) int primaryNormal;

@Inject @VideoSizePercentage IntPreference videoSizePreference;
@Inject @ShowCountdown BooleanPreference showCountdownPreference;
Expand All @@ -40,16 +45,14 @@ public final class TelecineActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Resources res = getResources();
String taskName = res.getString(R.string.app_name);
Bitmap taskIcon = BitmapFactory.decodeResource(res, R.drawable.ic_videocam_white_48dp);
int taskColor = res.getColor(R.color.primary_normal);
setTaskDescription(new ActivityManager.TaskDescription(taskName, taskIcon, taskColor));

((TelecineApplication) getApplication()).inject(this);

setContentView(R.layout.activity_main);
ButterKnife.inject(this);
ButterKnife.bind(this);

Resources res = getResources();
Bitmap taskIcon = BitmapFactory.decodeResource(res, R.drawable.ic_videocam_white_48dp);
setTaskDescription(new ActivityManager.TaskDescription(appName, taskIcon, primaryNormal));

videoSizePercentageAdapter = new VideoSizePercentageAdapter(this);

Expand Down

0 comments on commit e3df2d4

Please sign in to comment.