Skip to content

Commit 09e52d9

Browse files
Testing Push/Editing View Profile
1 parent 52408d9 commit 09e52d9

File tree

4 files changed

+49
-19
lines changed

4 files changed

+49
-19
lines changed

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/fakhouri/salim/quest/ViewProfile.java

+46-17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.os.Bundle;
88
import android.support.design.widget.CollapsingToolbarLayout;
99
import android.support.design.widget.FloatingActionButton;
10+
import android.support.design.widget.Snackbar;
1011
import android.support.v7.app.AppCompatActivity;
1112
import android.support.v7.graphics.Palette;
1213
import android.support.v7.widget.LinearLayoutManager;
@@ -25,9 +26,7 @@
2526

2627
import java.util.Map;
2728

28-
/**
29-
* Created by salim on 12/24/2015.
30-
*/
29+
3130
public class ViewProfile extends AppCompatActivity {
3231

3332
private ImageView header;
@@ -57,7 +56,10 @@ protected void onCreate(Bundle savedInstanceState) {
5756
setContentView(R.layout.view_profile_layout);
5857
toolbar = (Toolbar)findViewById(R.id.anim_toolbarView);
5958
setSupportActionBar(toolbar);
59+
60+
assert getSupportActionBar() != null;
6061
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
62+
6163
loadImageFromString = new LoadImageFromString(this);
6264
collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbarView);
6365
header = (ImageView) findViewById(R.id.headerView);
@@ -94,7 +96,7 @@ public void onDataChange(DataSnapshot dataSnapshot) {
9496
collapsingToolbarLayout.setTitle(mUser.getUsername());
9597
// pass the user to adapter
9698

97-
recyclerView = (RecyclerView)findViewById(R.id.scrollableviewView);
99+
recyclerView = (RecyclerView) findViewById(R.id.scrollableviewView);
98100
recyclerView.setHasFixedSize(true); // only one view
99101

100102
layoutManager = new LinearLayoutManager(ViewProfile.this);
@@ -107,21 +109,21 @@ public void onDataChange(DataSnapshot dataSnapshot) {
107109
userMapFriends = mUser.getFriends();
108110
// check to see if this user in the userMap friends
109111

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) {
112114
// this user is not a friend of your
113115
// and have not sent him before
114116
// do not change the icon
115-
Log.e("UserState",String.valueOf(userState));
117+
Log.e("UserState", String.valueOf(userState));
116118

117-
}else if(userState == 1){
119+
} else if (userState == 1) {
118120
// sent but no acceptance
119121
// 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) {
122124
// this user is your friend
123125
// change icon
124-
Log.e("UserState",String.valueOf(userState));
126+
Log.e("UserState", String.valueOf(userState));
125127

126128
}
127129
}
@@ -133,21 +135,48 @@ public void onCancelled(FirebaseError firebaseError) {
133135
});
134136
}
135137

136-
138+
if(mUser != null){
137139
floatingActionButton.setOnClickListener(new View.OnClickListener() {
138140
@Override
139141
public void onClick(View v) {
140142

141143
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();
145168

146-
// get inside the pend state (1)
147169

170+
// heeasd
171+
172+
173+
}
148174

149175
}
150176
});
177+
}
178+
179+
151180

152181

153182

@@ -162,7 +191,7 @@ private class PaletteBackground extends AsyncTask<String,Void,Bitmap>{
162191
@Override
163192
protected Bitmap doInBackground(String... params) {
164193
strImageHolder = params[0];
165-
Bitmap bitmap = null;
194+
Bitmap bitmap;
166195

167196
// decode the string
168197
try {

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':app'
1+
include ':app'

0 commit comments

Comments
 (0)