-
Notifications
You must be signed in to change notification settings - Fork 551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: View social links in event details #105
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c6505c8
organised ticket files to a folder and added social-link api and model
1060ef5
(wip) feat: view social links in event details
c148792
corrected the loading of social links
5f7c7bb
minor changes to social links ui
60fd583
added entry/exit animations and changed close button icon
10c2185
feat: Changed the icon colours to grey and recycler background to white
5c1ca37
feat: Add type converter for event
4dbb867
feat: make converter for event
8927662
feat: add eventid class
1b052ac
Merge branch 'development' into social_links
78b359a
fix: Make relationship nullable
iamareebjamal 7c2b03f
fix: made type converter for event alone
db8a87e
fix: remove unused imports and add foreign key
c77acd7
merge fix
b607085
s
2db574c
fix: Change single to flowable and refactor file names
acd7340
fix : table name typo fixed
120939f
fix : change method names
b554527
Merge branch 'development' into social_links
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 12 additions & 0 deletions
12
app/src/main/java/org/fossasia/openevent/general/event/EventId.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,12 @@ | ||
package org.fossasia.openevent.general.event | ||
|
||
import com.github.jasminb.jsonapi.LongIdHandler | ||
import com.github.jasminb.jsonapi.annotations.Id | ||
import com.github.jasminb.jsonapi.annotations.Relationship | ||
import com.github.jasminb.jsonapi.annotations.Type | ||
|
||
@Type("event") | ||
data class EventId( | ||
@Id(LongIdHandler::class) | ||
val id: Long | ||
) |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/org/fossasia/openevent/general/event/EventIdConverter.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 | ||
|
||
import android.arch.persistence.room.TypeConverter | ||
|
||
class EventIdConverter { | ||
|
||
@TypeConverter | ||
fun fromEventId(eventId: EventId): Long{ | ||
return eventId.id | ||
} | ||
|
||
@TypeConverter | ||
fun toEventId(id: Long): EventId{ | ||
return EventId(id) | ||
} | ||
} |
11 changes: 9 additions & 2 deletions
11
app/src/main/java/org/fossasia/openevent/general/social/SocialLink.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 |
---|---|---|
@@ -1,22 +1,29 @@ | ||
package org.fossasia.openevent.general.social | ||
|
||
import android.arch.persistence.room.* | ||
import android.arch.persistence.room.ColumnInfo | ||
import android.arch.persistence.room.Entity | ||
import android.arch.persistence.room.ForeignKey | ||
import android.arch.persistence.room.ForeignKey.CASCADE | ||
import android.arch.persistence.room.PrimaryKey | ||
import com.fasterxml.jackson.databind.PropertyNamingStrategy | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming | ||
import com.github.jasminb.jsonapi.IntegerIdHandler | ||
import com.github.jasminb.jsonapi.annotations.Id | ||
import com.github.jasminb.jsonapi.annotations.Relationship | ||
import com.github.jasminb.jsonapi.annotations.Type | ||
import org.fossasia.openevent.general.event.Event | ||
import org.fossasia.openevent.general.event.EventId | ||
|
||
@Type("social-link") | ||
@JsonNaming(PropertyNamingStrategy.KebabCaseStrategy::class) | ||
@Entity(foreignKeys = [(ForeignKey(entity = Event::class, parentColumns = ["id"], childColumns = ["event"], onDelete = CASCADE))]) | ||
data class SocialLink( | ||
@Id(IntegerIdHandler::class) | ||
@PrimaryKey | ||
val id: Int, | ||
val link: String, | ||
val name: String, | ||
@ColumnInfo(index = true) | ||
@Relationship("event") | ||
val event: Event | ||
var event: EventId? = null | ||
) |
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
19 changes: 19 additions & 0 deletions
19
app/src/main/java/org/fossasia/openevent/general/social/SocialLinksDao.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,19 @@ | ||
package org.fossasia.openevent.general.social | ||
|
||
import android.arch.persistence.room.Dao | ||
import android.arch.persistence.room.Insert | ||
import android.arch.persistence.room.OnConflictStrategy | ||
import android.arch.persistence.room.Query | ||
import io.reactivex.Flowable | ||
|
||
@Dao | ||
interface SocialLinksDao { | ||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
fun insertSocialLinks(socialLinks: List<SocialLink>) | ||
|
||
@Query("DELETE FROM SocialLink") | ||
fun deleteAll() | ||
|
||
@Query("SELECT * from SocialLink WHERE event = :eventId") | ||
fun getAllSocialLinks(eventId: Long): Flowable<List<SocialLink>> | ||
} |
70 changes: 70 additions & 0 deletions
70
app/src/main/java/org/fossasia/openevent/general/social/SocialLinksFragment.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,70 @@ | ||
package org.fossasia.openevent.general.social | ||
|
||
import android.arch.lifecycle.Observer | ||
import android.os.Bundle | ||
import android.support.v4.app.Fragment | ||
import android.support.v7.widget.LinearLayoutManager | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import kotlinx.android.synthetic.main.fragment_social_links.view.* | ||
import org.fossasia.openevent.general.R | ||
import org.koin.android.architecture.ext.viewModel | ||
import timber.log.Timber | ||
|
||
class SocialLinksFragment : Fragment() { | ||
private val socialLinksRecyclerAdapter: SocialLinksRecyclerAdapter = SocialLinksRecyclerAdapter() | ||
private val socialLinksViewModel by viewModel<SocialLinksViewModel>() | ||
private lateinit var rootView: View | ||
private var id: Long = -1 | ||
private val EVENT_ID: String = "EVENT_ID" | ||
private lateinit var linearLayoutManager: LinearLayoutManager | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
val bundle = this.arguments | ||
if (bundle != null) { | ||
id = bundle.getLong(EVENT_ID, -1) | ||
} | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle?): View? { | ||
rootView = inflater.inflate(R.layout.fragment_social_links, container, false) | ||
|
||
rootView.progressBarSocial.isIndeterminate = true | ||
|
||
linearLayoutManager = LinearLayoutManager(context) | ||
linearLayoutManager.orientation = LinearLayoutManager.HORIZONTAL | ||
rootView.socialLinksRecycler.layoutManager = linearLayoutManager | ||
|
||
rootView.socialLinksRecycler.adapter = socialLinksRecyclerAdapter | ||
rootView.socialLinksRecycler.isNestedScrollingEnabled = false | ||
|
||
socialLinksViewModel.socialLinks.observe(this, Observer { | ||
it?.let { | ||
socialLinksRecyclerAdapter.addAll(it) | ||
} | ||
socialLinksRecyclerAdapter.notifyDataSetChanged() | ||
Timber.d("Fetched social-links of size %s", socialLinksRecyclerAdapter.itemCount) | ||
}) | ||
|
||
socialLinksViewModel.error.observe(this, Observer { | ||
Toast.makeText(context, it, Toast.LENGTH_LONG).show() | ||
}) | ||
|
||
socialLinksViewModel.progress.observe(this, Observer { | ||
it?.let { showProgressBar(it) } | ||
}) | ||
|
||
socialLinksViewModel.loadSocialLinks(id) | ||
|
||
return rootView | ||
} | ||
|
||
private fun showProgressBar(show: Boolean) { | ||
rootView.progressBarSocial.isIndeterminate = show | ||
rootView.progressBarSocial.visibility = if (show) View.VISIBLE else View.GONE | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamareebjamal why is eventid class here would it be needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes