7
7
import android .os .Bundle ;
8
8
import android .support .design .widget .CollapsingToolbarLayout ;
9
9
import android .support .design .widget .FloatingActionButton ;
10
+ import android .support .design .widget .Snackbar ;
10
11
import android .support .v7 .app .AppCompatActivity ;
11
12
import android .support .v7 .graphics .Palette ;
12
13
import android .support .v7 .widget .LinearLayoutManager ;
25
26
26
27
import java .util .Map ;
27
28
28
- /**
29
- * Created by salim on 12/24/2015.
30
- */
29
+
31
30
public class ViewProfile extends AppCompatActivity {
32
31
33
32
private ImageView header ;
@@ -57,7 +56,10 @@ protected void onCreate(Bundle savedInstanceState) {
57
56
setContentView (R .layout .view_profile_layout );
58
57
toolbar = (Toolbar )findViewById (R .id .anim_toolbarView );
59
58
setSupportActionBar (toolbar );
59
+
60
+ assert getSupportActionBar () != null ;
60
61
getSupportActionBar ().setDisplayHomeAsUpEnabled (true );
62
+
61
63
loadImageFromString = new LoadImageFromString (this );
62
64
collapsingToolbarLayout = (CollapsingToolbarLayout ) findViewById (R .id .collapsing_toolbarView );
63
65
header = (ImageView ) findViewById (R .id .headerView );
@@ -94,7 +96,7 @@ public void onDataChange(DataSnapshot dataSnapshot) {
94
96
collapsingToolbarLayout .setTitle (mUser .getUsername ());
95
97
// pass the user to adapter
96
98
97
- recyclerView = (RecyclerView )findViewById (R .id .scrollableviewView );
99
+ recyclerView = (RecyclerView ) findViewById (R .id .scrollableviewView );
98
100
recyclerView .setHasFixedSize (true ); // only one view
99
101
100
102
layoutManager = new LinearLayoutManager (ViewProfile .this );
@@ -107,21 +109,21 @@ public void onDataChange(DataSnapshot dataSnapshot) {
107
109
userMapFriends = mUser .getFriends ();
108
110
// check to see if this user in the userMap friends
109
111
110
- userState = (Integer )userMapFriends .get (author ); // the author id of this particular user
111
- if (userState == null ){
112
+ userState = (Integer ) userMapFriends .get (author ); // the author id of this particular user
113
+ if (userState == null ) {
112
114
// this user is not a friend of your
113
115
// and have not sent him before
114
116
// do not change the icon
115
- Log .e ("UserState" ,String .valueOf (userState ));
117
+ Log .e ("UserState" , String .valueOf (userState ));
116
118
117
- }else if (userState == 1 ){
119
+ } else if (userState == 1 ) {
118
120
// sent but no acceptance
119
121
// change the icon
120
- Log .e ("UserState" ,String .valueOf (userState ));
121
- }else if (userState == 2 ){
122
+ Log .e ("UserState" , String .valueOf (userState ));
123
+ } else if (userState == 2 ) {
122
124
// this user is your friend
123
125
// change icon
124
- Log .e ("UserState" ,String .valueOf (userState ));
126
+ Log .e ("UserState" , String .valueOf (userState ));
125
127
126
128
}
127
129
}
@@ -133,21 +135,48 @@ public void onCancelled(FirebaseError firebaseError) {
133
135
});
134
136
}
135
137
136
-
138
+ if ( mUser != null ){
137
139
floatingActionButton .setOnClickListener (new View .OnClickListener () {
138
140
@ Override
139
141
public void onClick (View v ) {
140
142
141
143
Log .e ("userStateHello" ,"floating is clicked" );
142
- // change the icon
143
- floatingActionButton .setImageResource (R .drawable .ic_action_time );
144
- // request an add friend
144
+ /*
145
+ check the state of the user
146
+ */
147
+ if (userState == null ){
148
+ // change the icon
149
+ floatingActionButton .setImageResource (R .drawable .ic_action_time );
150
+ // use parse to send a push request an add friend
151
+
152
+ // update the hashmap of this user's friends
153
+ }else if (userState == 1 ){
154
+ // pending state
155
+ // do not change the icon
156
+ // let user know that his request has been sent
157
+ Snackbar .make (v , "A Request Has Already Been Sent" , Snackbar .LENGTH_LONG )
158
+ .setAction ("Action" , null ).show ();
159
+ }else if (userState == 2 ){
160
+ // you are friened with this user
161
+ // onclick , pop up dialog
162
+ // ask if you want to unfriend this user
163
+ // if so
164
+ // delete this user(author) from the hashmap
165
+ // and delete this user (current) from author's hashmap
166
+ //Snackbar.make(v, "A Request Has Already Been Sent", Snackbar.LENGTH_LONG)
167
+ // .setAction("Action", null).show();
145
168
146
- // get inside the pend state (1)
147
169
170
+ // heeasd
171
+
172
+
173
+ }
148
174
149
175
}
150
176
});
177
+ }
178
+
179
+
151
180
152
181
153
182
@@ -162,7 +191,7 @@ private class PaletteBackground extends AsyncTask<String,Void,Bitmap>{
162
191
@ Override
163
192
protected Bitmap doInBackground (String ... params ) {
164
193
strImageHolder = params [0 ];
165
- Bitmap bitmap = null ;
194
+ Bitmap bitmap ;
166
195
167
196
// decode the string
168
197
try {
0 commit comments