-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d3a586
commit 231c74d
Showing
12 changed files
with
195 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/src/main/java/org/fossasia/openevent/general/event/feedback/Feedback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.fossasia.openevent.general.event.feedback | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import com.github.jasminb.jsonapi.LongIdHandler | ||
import com.github.jasminb.jsonapi.annotations.Id | ||
import com.github.jasminb.jsonapi.annotations.Type | ||
|
||
@Type("feedback") | ||
data class Feedback( | ||
@Id(LongIdHandler::class) | ||
val id: Long, | ||
val rating: String?, | ||
val comment: String?, | ||
@JsonProperty("deleted-at") | ||
val deletedAt: String? | ||
|
||
) |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/org/fossasia/openevent/general/event/feedback/FeedbackApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.fossasia.openevent.general.event.feedback | ||
|
||
import io.reactivex.Single | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
|
||
interface FeedbackApi { | ||
|
||
@GET("events/{eventId}/feedbacks") | ||
fun getEventFeedback( | ||
@Path("eventId") eventId: Long, | ||
@Query("sort") sort: String = "rating", | ||
@Query("filter") eventName: String = "[]" | ||
): Single<List<Feedback>> | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/org/fossasia/openevent/general/event/feedback/FeedbackRecyclerAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.fossasia.openevent.general.event.feedback | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import org.fossasia.openevent.general.R | ||
|
||
class FeedbackRecyclerAdapter : RecyclerView.Adapter<FeedbackViewHolder>() { | ||
val feedbackList = ArrayList<Feedback>() | ||
|
||
fun addAll(feedbackList: List<Feedback>) { | ||
if (feedbackList.isNotEmpty()) | ||
this.feedbackList.clear() | ||
this.feedbackList.addAll(feedbackList) | ||
notifyDataSetChanged() | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FeedbackViewHolder { | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_feedback, parent, false) | ||
return FeedbackViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: FeedbackViewHolder, position: Int) { | ||
val feedback = feedbackList[position] | ||
|
||
holder.bind(feedback) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return feedbackList.size | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/fossasia/openevent/general/event/feedback/FeedbackViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.fossasia.openevent.general.event.feedback | ||
|
||
import android.view.View | ||
import androidx.recyclerview.widget.RecyclerView | ||
import kotlinx.android.synthetic.main.item_feedback.view.commentTv | ||
import kotlinx.android.synthetic.main.item_feedback.view.ratingBar | ||
|
||
class FeedbackViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
|
||
fun bind(feedback: Feedback) { | ||
itemView.commentTv.text = feedback.comment | ||
itemView.ratingBar.rating = feedback.rating?.toFloat() ?: 0f | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" android:layout_width="match_parent" | ||
android:layout_marginStart="@dimen/layout_margin_large" | ||
android:layout_marginTop="@dimen/layout_margin_small" | ||
android:layout_marginBottom="@dimen/layout_margin_small" | ||
android:layout_marginEnd="@dimen/layout_margin_large" | ||
android:layout_height="wrap_content"> | ||
<RatingBar | ||
android:id="@+id/ratingBar" | ||
android:numStars="5" | ||
style="@style/Widget.AppCompat.RatingBar.Small" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<TextView | ||
android:id="@+id/commentTv" | ||
android:layout_marginTop="@dimen/layout_margin_small" | ||
android:textColor="@color/black" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters