Skip to content

Commit c56e7f4

Browse files
FINISHED WITH OPENED QUEST/ users now can finish the quest all together/ can upload pictures to the quest and view them
1 parent 32ad032 commit c56e7f4

31 files changed

+1087
-216
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.

app/build.gradle

+5-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ dependencies {
6262
// image shapes
6363
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
6464

65-
//sticky
66-
compile 'se.emilsjolander:StickyScrollViewItems:1.1.0'
65+
// progress bar
66+
compile 'com.liulishuo.magicprogresswidget:library:1.0.2'
67+
68+
// swipe
69+
compile "com.daimajia.swipelayout:library:1.2.0@aar"
6770

6871
compile 'com.jakewharton:butterknife:7.0.1'
6972

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.skuares.studio.quest;
2+
3+
import android.annotation.TargetApi;
4+
import android.content.Context;
5+
import android.os.Build;
6+
import android.util.AttributeSet;
7+
import android.widget.TextView;
8+
9+
/**
10+
* Created by Jacksgong on 12/11/15.
11+
*/
12+
/*
13+
Copyright (c) 2015 LingoChamp Inc.
14+
15+
Licensed under the Apache License, Version 2.0 (the "License");
16+
you may not use this file except in compliance with the License.
17+
You may obtain a copy of the License at
18+
19+
http://www.apache.org/licenses/LICENSE-2.0
20+
21+
Unless required by applicable law or agreed to in writing, software
22+
distributed under the License is distributed on an "AS IS" BASIS,
23+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24+
See the License for the specific language governing permissions and
25+
limitations under the License.
26+
*/
27+
public class AnimTextView extends TextView {
28+
public AnimTextView(Context context) {
29+
super(context);
30+
}
31+
32+
public AnimTextView(Context context, AttributeSet attrs) {
33+
super(context, attrs);
34+
}
35+
36+
public AnimTextView(Context context, AttributeSet attrs, int defStyleAttr) {
37+
super(context, attrs, defStyleAttr);
38+
}
39+
40+
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
41+
public AnimTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
42+
super(context, attrs, defStyleAttr, defStyleRes);
43+
}
44+
45+
private int score;
46+
47+
public void setScore(final int score) {
48+
this.score = score;
49+
setText(String.valueOf(score));
50+
}
51+
52+
public int getScore() {
53+
return this.score;
54+
}
55+
}

app/src/main/java/com/skuares/studio/quest/CreateQuest.java

+24-59
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353

5454
import java.io.InputStream;
5555
import java.util.ArrayList;
56+
import java.util.HashMap;
5657
import java.util.List;
58+
import java.util.Map;
5759

5860
import static com.skuares.studio.quest.UserProfile.getPath;
5961

@@ -79,6 +81,8 @@ public class CreateQuest extends AppCompatActivity{
7981

8082
LoadImageFromPath loadImageFromPath;
8183

84+
private Map<String,Object> participants;
85+
8286
/*
8387
Todos Dialg layout
8488
*/
@@ -137,6 +141,7 @@ protected void onCreate(Bundle savedInstanceState) {
137141
loadImageFromPath = new LoadImageFromPath(this);
138142
// initialize the list
139143
todosList = new ArrayList<ToDo>();
144+
140145
// reference
141146
questImageAdd = (ImageView)findViewById(R.id.questImageAdd);
142147
questUserImageAdd = (ImageView)findViewById(R.id.questUserImageAdd);
@@ -149,6 +154,10 @@ protected void onCreate(Bundle savedInstanceState) {
149154

150155
// get user
151156
if(MainActivity.myUser != null){
157+
// initialize the todo map and get it ready
158+
participants = new HashMap<String, Object>();
159+
participants.put(MainActivity.uid,false);
160+
152161
userQuest = MainActivity.myUser;
153162

154163
// get user image and get usernamse
@@ -175,6 +184,9 @@ public void onClick(View v) {
175184
questDesc = questDescriptionAdd.getText().toString();
176185
questTitle = questTitleAdd.getText().toString();
177186

187+
/*
188+
189+
*/
178190
// check list
179191
if(todosList == null || todosList.size() == 0){
180192
Toast.makeText(CreateQuest.this,"You must add a todos",Toast.LENGTH_LONG).show();
@@ -203,6 +215,11 @@ public void onClick(View v) {
203215
return;
204216
}
205217

218+
// done validating take the user to the next page
219+
220+
221+
//
222+
206223
// we need to meausre the cost
207224
double sumMoney = 0;
208225
int hours = 0;
@@ -250,63 +267,6 @@ public void onClick(View v) {
250267

251268
}
252269

253-
/*
254-
255-
protected synchronized void buildGoogleApiClient() {
256-
mGoogleApiClient = new GoogleApiClient.Builder(this)
257-
.addConnectionCallbacks(this)
258-
.addOnConnectionFailedListener(this)
259-
.addApi(LocationServices.API)
260-
.addApi(Places.GEO_DATA_API)
261-
.build();
262-
}
263-
264-
@Override
265-
public void onConnected(Bundle bundle) {
266-
Toast.makeText(this, "Connection true",Toast.LENGTH_SHORT).show();
267-
}
268-
269-
@Override
270-
public void onConnectionSuspended(int i) {
271-
Toast.makeText(this, "Connection Suspended",Toast.LENGTH_SHORT).show();
272-
}
273-
274-
@Override
275-
public void onConnectionFailed(ConnectionResult connectionResult) {
276-
Toast.makeText(this, "Connection Failed",Toast.LENGTH_SHORT).show();
277-
278-
}
279-
*/
280-
281-
282-
/*
283-
@Override
284-
protected void onStart() {
285-
super.onStart();
286-
287-
if (!mGoogleApiClient.isConnected() && !mGoogleApiClient.isConnecting()){
288-
Log.v("Google API","Connecting");
289-
mGoogleApiClient.connect();
290-
}
291-
}
292-
293-
@Override
294-
protected void onPause() {
295-
if(mGoogleApiClient.isConnected()){
296-
Log.v("Google API","Dis-Connecting");
297-
mGoogleApiClient.disconnect();
298-
}
299-
super.onPause();
300-
}
301-
302-
@Override
303-
protected void onResume() {
304-
super.onResume();
305-
306-
}
307-
*/
308-
309-
310270

311271

312272
class GetCompressedImageThenSave extends AsyncTask<Object,Void,Bitmap>{
@@ -549,16 +509,21 @@ public void onClick(View v) {
549509
String time = addTimeDialog.getText().toString();
550510
String money = addMoneyDialog.getText().toString();
551511

512+
513+
552514
if(desc.equals("") || time.equals("") || money.equals("")){
553515
Toast.makeText(CreateQuest.this,"Please Fill In The Fields",Toast.LENGTH_SHORT).show();
554516
return;
555517
}
556518

519+
520+
557521
double moneys = Double.parseDouble(money);
558522
// create a to--do object
559523
APlace aPlace1 = aPlace[0];
560-
if(aPlace1 != null){
561-
toDo = new ToDo(desc,time,moneys,aPlace1);
524+
if(aPlace1 != null && participants != null){
525+
526+
toDo = new ToDo(desc,time,moneys,aPlace1,participants,0); // usersFinishedThisTodo 0 by default
562527
// add it to the list
563528
todosList.add(toDo);
564529
// call adapter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.skuares.studio.quest;
2+
3+
import android.support.v7.widget.RecyclerView;
4+
5+
/**
6+
* Created by salim on 1/19/2016.
7+
*/
8+
public abstract class HidingScrollListener extends
9+
RecyclerView.OnScrollListener {
10+
private static final int HIDE_THRESHOLD = 20;
11+
private int scrolledDistance = 0;
12+
private boolean controlsVisible = true;
13+
14+
@Override
15+
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
16+
super.onScrolled(recyclerView, dx, dy);
17+
18+
if (scrolledDistance > HIDE_THRESHOLD && controlsVisible) {
19+
onHide();
20+
controlsVisible = false;
21+
scrolledDistance = 0;
22+
} else if (scrolledDistance < -HIDE_THRESHOLD && !controlsVisible) {
23+
onShow();
24+
controlsVisible = true;
25+
scrolledDistance = 0;
26+
27+
}
28+
29+
if ((controlsVisible && dy > 0) || (!controlsVisible && dy < 0)) {
30+
scrolledDistance += dy;
31+
}
32+
}
33+
34+
public abstract void onHide();
35+
36+
public abstract void onShow();
37+
}

app/src/main/java/com/skuares/studio/quest/MapActivity.java

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ protected void onCreate(Bundle savedInstanceState) {
4545

4646
}
4747

48+
4849
@Override
4950
public boolean onOptionsItemSelected(MenuItem item) {
5051

app/src/main/java/com/skuares/studio/quest/QJoinStreamFragment.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void onDataChange(DataSnapshot dataSnapshot) {
129129

130130

131131
// use the full data constructor
132-
adapterQuest[0] = new QuestCard(questCardsHolders.get(i[0]).getQuestImage(), questCardsHolders.get(i[0]).getQuestTitle(), questCardsHolders.get(i[0]).getAuthorId(), username[0], userImage[0], questCardsHolders.get(i[0]).getQuestDescription(), questCardsHolders.get(i[0]).getQuestCost(), questCardsHolders.get(i[0]).getTodos(),questCardsHolders.get(i[0]).getQuestKey(),questCardsHolders.get(i[0]).getUsersWhoLiked(),questCardsHolders.get(i[0]).getTakers(),questCardsHolders.get(i[0]).getNumberOfLikes(),questCardsHolders.get(i[0]).getNumberOfTakers(),questCardsHolders.get(i[0]).getJoiners());
132+
adapterQuest[0] = new QuestCard(questCardsHolders.get(i[0]).getQuestImage(), questCardsHolders.get(i[0]).getQuestTitle(), questCardsHolders.get(i[0]).getAuthorId(), username[0], userImage[0], questCardsHolders.get(i[0]).getQuestDescription(), questCardsHolders.get(i[0]).getQuestCost(), questCardsHolders.get(i[0]).getTodos(),questCardsHolders.get(i[0]).getQuestKey(),questCardsHolders.get(i[0]).getUsersWhoLiked(),questCardsHolders.get(i[0]).getTakers(),questCardsHolders.get(i[0]).getNumberOfLikes(),questCardsHolders.get(i[0]).getNumberOfTakers(),questCardsHolders.get(i[0]).getNumberOfFollowers(),questCardsHolders.get(i[0]).getJoiners());
133133
// increment i so we the next one next time
134134
i[0] = i[0] + 1;
135135
//Log.e("onchild",String.valueOf(i[0]));
@@ -171,17 +171,17 @@ public void onChildChanged(DataSnapshot dataSnapshot, String s) {
171171
QuestCard updatedQuestCard = dataSnapshot.getValue(QuestCard.class);
172172
// get the keyy and index it into the map
173173
String key = updatedQuestCard.getQuestKey();
174-
Log.e("indexes", "" + key);
174+
//Log.e("indexes", "" + key);
175175
QuestCard oldQuest = map.get(key);
176-
Log.e("indexes",""+oldQuest.getQuestKey());
176+
//Log.e("indexes",""+oldQuest.getQuestKey());
177177
if(oldQuest == null){
178178
// not of interest to this user
179179
}else{
180180
// get the index of the oldQuest
181181
int index = questCards.indexOf(oldQuest);
182182
// use this index to update the quest
183-
Log.e("indexes",""+index);
184-
Log.e("indexes", "" + questCards.size());
183+
//Log.e("indexes",""+index);
184+
//Log.e("indexes", "" + questCards.size());
185185
if(index >= 0){// because of the firebase issue of calling ondatachanged many times
186186
questCards.set(index,updatedQuestCard);
187187
// notify the adapter

app/src/main/java/com/skuares/studio/quest/QOwnStreamFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void onDataChange(DataSnapshot dataSnapshot) {
133133

134134

135135
// use the full data constructor
136-
adapterQuest[0] = new QuestCard(questCardsHolders.get(i[0]).getQuestImage(), questCardsHolders.get(i[0]).getQuestTitle(), questCardsHolders.get(i[0]).getAuthorId(), username[0], userImage[0], questCardsHolders.get(i[0]).getQuestDescription(), questCardsHolders.get(i[0]).getQuestCost(), questCardsHolders.get(i[0]).getTodos(),questCardsHolders.get(i[0]).getQuestKey(),questCardsHolders.get(i[0]).getUsersWhoLiked(),questCardsHolders.get(i[0]).getTakers(),questCardsHolders.get(i[0]).getNumberOfLikes(),questCardsHolders.get(i[0]).getNumberOfTakers(),questCardsHolders.get(i[0]).getJoiners());
136+
adapterQuest[0] = new QuestCard(questCardsHolders.get(i[0]).getQuestImage(), questCardsHolders.get(i[0]).getQuestTitle(), questCardsHolders.get(i[0]).getAuthorId(), username[0], userImage[0], questCardsHolders.get(i[0]).getQuestDescription(), questCardsHolders.get(i[0]).getQuestCost(), questCardsHolders.get(i[0]).getTodos(),questCardsHolders.get(i[0]).getQuestKey(),questCardsHolders.get(i[0]).getUsersWhoLiked(),questCardsHolders.get(i[0]).getTakers(),questCardsHolders.get(i[0]).getNumberOfLikes(),questCardsHolders.get(i[0]).getNumberOfTakers(),questCardsHolders.get(i[0]).getNumberOfFollowers(),questCardsHolders.get(i[0]).getJoiners());
137137
// increment i so we the next one next time
138138
i[0] = i[0] + 1;
139139
//Log.e("onchild",String.valueOf(i[0]));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.skuares.studio.quest;
2+
3+
import android.graphics.Bitmap;
4+
import android.util.Base64;
5+
6+
import com.shaded.fasterxml.jackson.annotation.JsonProperty;
7+
8+
import java.io.ByteArrayOutputStream;
9+
10+
/**
11+
* Created by salim on 1/23/2016.
12+
*/
13+
public class QPicture {
14+
15+
private String owner;
16+
private String stringPicture;
17+
18+
19+
public QPicture() {
20+
}
21+
22+
23+
24+
// retrieve the picture data
25+
public QPicture(@JsonProperty("owner") String owner,
26+
@JsonProperty("stringPicture") String stringPicture
27+
){
28+
29+
this.owner = owner;
30+
this.stringPicture = stringPicture;
31+
}
32+
33+
34+
public String getOwner() {
35+
return owner;
36+
}
37+
38+
public String getStringPicture() {
39+
return stringPicture;
40+
}
41+
42+
public static String bitmapToString(Bitmap bitmap){
43+
44+
45+
// output stream to write for when using compress
46+
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
47+
bitmap.compress(Bitmap.CompressFormat.PNG,50,outputStream);
48+
bitmap.recycle();
49+
// convert the output stream to byte array
50+
byte[] bytes = outputStream.toByteArray();
51+
// convert byte[] to string
52+
String stringImage = Base64.encodeToString(bytes, Base64.DEFAULT);
53+
54+
return stringImage;
55+
}
56+
}

0 commit comments

Comments
 (0)