From 1c062fd0ee0ebdb5414122abdc91e86cc8517b35 Mon Sep 17 00:00:00 2001 From: rizkihalasan <13515095@std.stei.itb.ac.id> Date: Sat, 17 Feb 2018 15:33:08 +0700 Subject: [PATCH] add fragment button --- app/build.gradle | 1 + .../leo/fitnessdiy/ExerciseFragment.java | 19 +++++++++++++++++- .../example/leo/fitnessdiy/HomeActivity.java | 14 ++++++++----- app/src/main/res/drawable/chat_icon.png | Bin 0 -> 2162 bytes app/src/main/res/layout/activity_home.xml | 13 +++++++++--- app/src/main/res/layout/fragment_exercise.xml | 11 +++++----- 6 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 app/src/main/res/drawable/chat_icon.png diff --git a/app/build.gradle b/app/build.gradle index a86e27e..c13d8b2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -28,6 +28,7 @@ dependencies { androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' compile 'com.squareup.okhttp3:okhttp:3.8.1' compile 'com.android.support:cardview-v7:26.1.0' + compile 'com.android.support:design:26.1.0' compile 'com.android.support:recyclerview-v7:26.1.0' compile 'com.github.bumptech.glide:glide:4.2.0' } diff --git a/app/src/main/java/com/example/leo/fitnessdiy/ExerciseFragment.java b/app/src/main/java/com/example/leo/fitnessdiy/ExerciseFragment.java index 41f289e..ec8becc 100644 --- a/app/src/main/java/com/example/leo/fitnessdiy/ExerciseFragment.java +++ b/app/src/main/java/com/example/leo/fitnessdiy/ExerciseFragment.java @@ -1,12 +1,14 @@ package com.example.leo.fitnessdiy; import android.content.Context; +import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; /** @@ -64,7 +66,16 @@ public class ExerciseFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_exercise, container, false); + View view = inflater.inflate(R.layout.fragment_exercise, container, false); + Button plankButton = (Button)view.findViewById(R.id.plank_button); + plankButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent i = new Intent(getActivity(), PlankActivity.class); + startActivity(i); + } + }); + return view; } // TODO: Rename method, update argument and hook method into UI event @@ -105,4 +116,10 @@ public class ExerciseFragment extends Fragment { // TODO: Update argument type and name void onFragmentInteraction(Uri uri); } + + + + + + } diff --git a/app/src/main/java/com/example/leo/fitnessdiy/HomeActivity.java b/app/src/main/java/com/example/leo/fitnessdiy/HomeActivity.java index 11bedcf..ea1a067 100644 --- a/app/src/main/java/com/example/leo/fitnessdiy/HomeActivity.java +++ b/app/src/main/java/com/example/leo/fitnessdiy/HomeActivity.java @@ -2,6 +2,7 @@ package com.example.leo.fitnessdiy; import android.content.Intent; import android.net.Uri; +import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; @@ -13,6 +14,7 @@ public class HomeActivity extends AppCompatActivity implements ExerciseFragment.OnFragmentInteractionListener, HistoryFragment.OnFragmentInteractionListener{ + private FloatingActionButton chatButton; @Override public void onFragmentInteraction(Uri uri) { @@ -23,6 +25,8 @@ public class HomeActivity extends AppCompatActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); + chatButton = findViewById(R.id.chat_button); + chatButton.setImageResource(R.drawable.chat_icon); } public void openHistory(View view) { @@ -30,10 +34,7 @@ public class HomeActivity extends AppCompatActivity startActivity(i); } - public void startExcercise(View view) { - Intent i = new Intent(getApplicationContext(), ExerciseActivity.class); - startActivity(i); - } + public void changeFragment(View view){ Fragment fragment; @@ -45,7 +46,7 @@ public class HomeActivity extends AppCompatActivity ft.replace(R.id.home_fragment, fragment); ft.commit(); } - if(view == findViewById(R.id.exercise_button)){ + else if(view == findViewById(R.id.exercise_button)){ fragment = new ExerciseFragment(); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); @@ -54,4 +55,7 @@ public class HomeActivity extends AppCompatActivity } } + public void goToChat(View view) { + + } } diff --git a/app/src/main/res/drawable/chat_icon.png b/app/src/main/res/drawable/chat_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3f8679dc97ac5fe57e9b22b6ba79c76e2c8792db GIT binary patch literal 2162 zcmV-&2#xoNP)<h;3K|Lk000e1NJLTq00B$@009^X0{{R30Ixrc0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUyGf+%aMF5%q5TF0=`Tu{+|DW0aK(qh9 z<^M3O|KIZe&+PvorvG5S|4_OAaK`_y-~W%&|NsC0Tz~&m0000HbW%=J|NsC0|NsC0 z|NsC0|NsC0041%NVgLXKxJg7oRCwC#-Pv~QAPfaiF&fYM|F6AC+S?(G69ck?%{i~_ zL)Kn^1fGZsOYnX+#<)uwdXVP&m+|r+-uu#iI~DRf+6!U-nD1FS=Zu-W2Il8TG^6V% zH*PT2SB$Cs+&dCY=ZtM@!_?jk9c>jizDaa{%+~e|Z69a$UrG1HZ0AAIerd)@pA$3e z3;7M|Pll<dzN5EA4K|zwGt7?Op2oDt$85)j3Q0G%N5*W&j*800p4(vtQ<&uEe4oS7 zFtu%{*bMean7*g7qx$w3n0oH$0CBc_%;E>-kKt)T(U{iJq0;+OF%L4oH=ONanA#{h zWI9_K=3yy6ICVjoho=0fMY<5o!&BZk=MpeaK`FF$=3?58PLpnWE2eMgRB`@om|>vP zrPuGlJj-HvU)bM(={q`UI=?ff9_YkLo$G0slcG~c+1)UMqtnNQeK4(}3X-xVBCM8+ zgHvyfIVq|pYT6caq^dIN?Jz?_m8EI7!mMeECpAeCn1-rMzX7IpRB0M5joCI-ZB#3Z z=@r!+D~V~T@)$YHk*ZHGh1tV$T^S;5#^p3$V(JEtYc&a$axD_UQcja#DW^%Wl+z?w z#%YE`Ojt(NbV9E#r%AAk){MuTp%%SQC!7<-XN<#a708~%#$ak#K2IBgiKggPyQx=W z;xIU^q!WsdToED^pTtb7FtK2!?$QYhrrfgm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?o>Z9h3F*#InJM5|rWG?2V4%IL?2hF=+Rxmgtn#)|w)32PP<{dFlUDg|) zh?0uQ>`%JAR3@1u9rL7xs1N)W%oEOa=W{%=Fwgb~R%i1x@-Q_POF2w?CQ8lk#q2>T zhp9j*hB<*!4)YANyql#c^Ds~FG<9QHFjR9b?>%!Vn8&_a*_psx4CbL<&^1gfpA5_y zgHjIjpqG7>^hzmmo_WmaZ8dXwm;)rmFaspzFwL>n$!T-R9L(eFej3yAK1szq$nK{Z zcNvnInB5^D1Miwd%)<L3<&4+7dlE6ry^z*9v-g0^#Pnqj$8mngc+ACY3LA{QnLNKg zR8A=$wfD0zgLA9euEx3182{d}n2)*53H#ldxA!;Nzq$UQ<sy@Uxy1`MRiQpxW42rL zgn{eC+@LKQG}no_!2!Ert`k$f`lyL(#T>9)ieZZ15z{l*iYYzGmF0Rd9j3S#rtr0j zk-1(>*#%R1t{7AHZBZv_)Dtm9-)?lC<}wXavcq(mtHvDB5Q$-0td?S!a+cl1TsNj% zQ#5L>98;_*axHV^m{OK!Ej%%pQl}e6bM=@)&H50StH+eFbe<WQB6n|emKm5L&qr25 z`5H6dQW<7oUNh%YY6hmrCbF{?QEvM^pla62HJEvpZej-J*CsOSa=2#(=2tR4f2>Sk z2Bt)_?krcDMa;xY<Z2Aez`RS+Bp)o-oF&YJhjyDeFauLy>(h-bSDz)!0g`f<>kl{@ zND58!q55@Fr~q}lKFfXR*68`7sRoN7xgPV$Zqm(IB_p?!_VI``9%u=tMt7f}d*@T} o$H(N*tB;4`3wfNo`1})K0B_jQ;y7u})c^nh07*qoM6N<$g8eWsi2wiq literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index 47a494b..8f7f8fa 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -27,12 +27,19 @@ android:text="@string/exercise" android:onClick="changeFragment"/> </LinearLayout> + <fragment - android:name="com.example.leo.fitnessdiy.ExerciseFragment" android:id="@+id/home_fragment" + android:name="com.example.leo.fitnessdiy.ExerciseFragment" android:layout_width="match_parent" - android:layout_height="match_parent" - /> + android:layout_height="471dp" /> + + <android.support.design.widget.FloatingActionButton + android:id="@+id/chat_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right" + android:onClick="goToChat"/> diff --git a/app/src/main/res/layout/fragment_exercise.xml b/app/src/main/res/layout/fragment_exercise.xml index 83fbd40..c28ca5d 100644 --- a/app/src/main/res/layout/fragment_exercise.xml +++ b/app/src/main/res/layout/fragment_exercise.xml @@ -4,10 +4,11 @@ android:layout_height="match_parent" tools:context="com.example.leo.fitnessdiy.ExerciseFragment"> - <!-- TODO: Update blank fragment layout --> - <TextView - android:layout_width="match_parent" - android:layout_height="match_parent" - android:text="EXERCISE" /> + <Button + android:id="@+id/plank_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Plank" + /> </FrameLayout> -- GitLab