implement Butterknife
This commit is contained in:
parent
60aa0ef517
commit
c0fe02026a
|
@ -24,4 +24,5 @@ dependencies {
|
|||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.1.1'
|
||||
compile 'joda-time:joda-time:2.9.1'
|
||||
compile 'com.jakewharton:butterknife:7.0.1'
|
||||
}
|
||||
|
|
|
@ -13,26 +13,29 @@ import org.joda.time.DateTime;
|
|||
|
||||
import java.text.DateFormatSymbols;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.BindColor;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
@Bind(R.id.left_arrow) ImageView leftArrow;
|
||||
@Bind(R.id.right_arrow) ImageView rightArrow;
|
||||
@Bind(R.id.table_month) TextView monthTV;
|
||||
@Bind(R.id.table_holder) TableLayout tableHolder;
|
||||
@BindColor(R.color.darkGrey) int grey;
|
||||
|
||||
private DateTime targetDate;
|
||||
private int grey;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
grey = getResources().getColor(R.color.darkGrey);
|
||||
|
||||
final ImageView leftArrow = (ImageView) findViewById(R.id.left_arrow);
|
||||
leftArrow.getDrawable().mutate().setColorFilter(grey, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
final ImageView rightArrow = (ImageView) findViewById(R.id.right_arrow);
|
||||
rightArrow.getDrawable().mutate().setColorFilter(grey, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
final TextView monthTV = (TextView) findViewById(R.id.table_month);
|
||||
|
||||
final TableLayout tableHolder = (TableLayout) findViewById(R.id.table_holder);
|
||||
final LayoutInflater inflater = getLayoutInflater();
|
||||
|
||||
final DateTime now = new DateTime();
|
||||
|
@ -71,6 +74,16 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.left_arrow)
|
||||
public void leftArrowClicked() {
|
||||
|
||||
}
|
||||
|
||||
@OnClick(R.id.right_arrow)
|
||||
public void rightArrowClicked() {
|
||||
|
||||
}
|
||||
|
||||
private String getMonthName() {
|
||||
final String[] months = new DateFormatSymbols().getMonths();
|
||||
return months[targetDate.getMonthOfYear() - 1];
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_alignBottom="@+id/table_month"
|
||||
android:layout_alignTop="@+id/table_month"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:src="@mipmap/arrow_left"/>
|
||||
|
||||
<TextView
|
||||
|
@ -33,7 +35,9 @@
|
|||
android:layout_alignBottom="@+id/table_month"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@+id/table_month"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:src="@mipmap/arrow_right"/>
|
||||
|
||||
<TableLayout
|
||||
|
|
Loading…
Reference in New Issue