Skip to content

Commit

Permalink
AIDEA775#58 link to ig bimo
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianYbarra committed Aug 12, 2023
1 parent 814ad86 commit 4389e8d
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 11 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/uncmorfi/shared/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const val COCINA_URL = "http://comedor.unc.edu.ar/cocina.php"
const val PROFILE_PIC_URL = "https://asiruws.unc.edu.ar/foto/"
const val SANAVIRON_URL = "https://autogestion.sanaviron.unc.edu.ar/micuenta"

const val SEC_BIMO_INSTAGRAM = "bienestarunc"
const val SEC_BIMO = "Bienestar estudiantil"
const val SEC_BIMO_IMAGE_URL = "https://instagram.fcor11-2.fna.fbcdn.net/v/t51.2885-19/334511791_3355595628037957_747727577920527220_n.jpg?stp=dst-jpg_s150x150&_nc_ht=instagram.fcor11-2.fna.fbcdn.net&_nc_cat=101&_nc_ohc=Cy02AXv5WLgAX_LlPGF&edm=ACWDqb8BAAAA&ccb=7-5&oh=00_AfC8gq9Jf8t29S39wsBXMwX_huB8gDlq4eSYPsedDjqHhQ&oe=64DD41B1&_nc_sid=ee9879"

const val ARG_CARD = "card"
const val ARG_USER = "user"

Expand Down
22 changes: 21 additions & 1 deletion app/src/main/java/com/uncmorfi/shared/Helper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.uncmorfi.shared
import android.app.Activity
import android.app.PendingIntent
import android.app.PendingIntent.FLAG_IMMUTABLE
import android.content.ActivityNotFoundException
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
Expand Down Expand Up @@ -162,6 +163,25 @@ fun Activity.openFacebook() {
}
}

fun Activity.openInstagram(user : String){
val userUrl = "http://instagram.com/stories/$user/"
val url = "http://instagram.com/$user"

val uri = Uri.parse(userUrl)
val intent = Intent(Intent.ACTION_VIEW, uri)
intent.setPackage("com.instagram.android")

try {
ContextCompat.startActivity(this,intent,null)
} catch (e: ActivityNotFoundException) {
ContextCompat.startActivity(this,
Intent(
Intent.ACTION_VIEW,
Uri.parse(url)
),null)
}
}

fun Activity.shareText(subject: String, text: String, title: String = "UNCmorfi"): Boolean {
val i = Intent(Intent.ACTION_SEND)
i.type = "text/plain"
Expand Down Expand Up @@ -231,4 +251,4 @@ fun TextView.updateVisibility() {

inline fun <T> LifecycleOwner.observe(liveData: LiveData<T>, crossinline body: (T) -> Unit) {
liveData.observe(this, { body.invoke(it) })
}
}
33 changes: 33 additions & 0 deletions app/src/main/java/com/uncmorfi/ui/menu/BiMoView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.uncmorfi.ui.menu

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import com.bumptech.glide.Glide
import com.google.android.material.card.MaterialCardView
import com.uncmorfi.R
import kotlinx.android.synthetic.main.view_bimo.view.bimoImageView
import kotlinx.android.synthetic.main.view_bimo.view.bimoTextView

class BiMoView @JvmOverloads constructor(
context: Context,
attr: AttributeSet? = null,
defStyleAttr: Int = 0
) : MaterialCardView(context, attr, defStyleAttr) {

init {
LayoutInflater.from(context).inflate(R.layout.view_bimo, this, true)
}

fun setImage(url : String){
Glide
.with(this)
.load(url)
.circleCrop()
.into(bimoImageView)
}

fun setName(name : String){
bimoTextView.setText(name)
}
}
9 changes: 9 additions & 0 deletions app/src/main/java/com/uncmorfi/ui/menu/MenuFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class MenuFragment : Fragment() {
swipeRefresh.init { viewModel.forceRefreshMenu() }
initRecyclerAndAdapter()
initMenu()
initBiMoUnc()

observe(viewModel.getMenu()) { menu ->
adapter.updateMenu(menu)
Expand Down Expand Up @@ -81,6 +82,14 @@ class MenuFragment : Fragment() {
menuRecyclerView.adapter = adapter
}

private fun initBiMoUnc() {
bimoCard.setImage(SEC_BIMO_IMAGE_URL)
bimoCard.setName(SEC_BIMO)
bimoCard.setOnClickListener {
requireActivity().openInstagram(SEC_BIMO_INSTAGRAM)
}
}

override fun onResume() {
super.onResume()
requireActivity().setTitle(R.string.navigation_menu)
Expand Down
35 changes: 25 additions & 10 deletions app/src/main/res/layout/fragment_menu.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".ui.menu.MenuFragment"
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
tools:context=".ui.menu.MenuFragment">

<com.uncmorfi.ui.menu.BiMoView
android:id="@+id/bimoCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/MaterialCard"
app:rippleColor="@null"
app:layout_constraintTop_toTopOf="parent"/>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/bimoCard">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/menuRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:clipToPadding="false"
android:scrollbars="none"
android:nestedScrollingEnabled="false"
android:paddingTop="8dp"
android:paddingBottom="64dp"
tools:listitem="@layout/item_menu">
</androidx.recyclerview.widget.RecyclerView>

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
android:scrollbars="none"
tools:listitem="@layout/item_menu" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
35 changes: 35 additions & 0 deletions app/src/main/res/layout/view_bimo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:parentTag="com.google.android.material.card.MaterialCardView">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/bimoImageView"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_margin="8dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/bimoTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginHorizontal="8dp"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
app:layout_constraintBottom_toBottomOf="@id/bimoImageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/bimoImageView"
app:layout_constraintTop_toTopOf="@id/bimoImageView" />

</androidx.constraintlayout.widget.ConstraintLayout>
</merge>

0 comments on commit 4389e8d

Please sign in to comment.