Skip to content

Commit

Permalink
added bird info
Browse files Browse the repository at this point in the history
  • Loading branch information
Deliner committed Sep 5, 2020
1 parent d6c9a3d commit 6a543d8
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 19 deletions.
19 changes: 13 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

<activity
android:name=".activity.StartActivity"
android:noHistory="true">
android:noHistory="true"
android:orientation="vertical">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -42,18 +43,24 @@

<activity
android:name=".activity.GreetActivity"
android:noHistory="true" />
android:noHistory="true"
android:orientation="vertical" />
<activity
android:name=".activity.JoinActivity"
android:noHistory="true" />
android:noHistory="true"
android:orientation="vertical" />
<activity
android:name=".activity.LoginActivity"
android:noHistory="true" />
android:noHistory="true"
android:orientation="vertical" />

<activity
android:name=".activity.BirdInfoActivity"
android:noHistory="true" />
android:noHistory="true"
android:orientation="vertical" />

<activity android:name=".activity.MainActivity" />
<activity
android:name=".activity.MainActivity"
android:orientation="vertical" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,21 +1,61 @@
package com.deliner.mosfauna.activity

import android.content.Intent
import android.media.MediaPlayer
import android.os.Bundle
import android.view.MenuItem
import android.widget.Button
import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
import com.deliner.mosfauna.R
import com.deliner.mosfauna.utils.LoginManager
import com.google.android.material.floatingactionbutton.FloatingActionButton

class BirdInfoActivity : UserActivity() {

private var photoId = -1


private lateinit var birdName: String


private lateinit var birdImageView: ImageView
private lateinit var birdNameView: TextView
private lateinit var birdEnglishNameView: TextView
private lateinit var birdInfoView: TextView
private lateinit var actionButton: FloatingActionButton
private lateinit var playSongButton: ImageView

private val audioPlayer = MediaPlayer()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
setContentView(R.layout.activity_bird_info)

setSupportActionBar(findViewById(R.id.toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)

birdName = intent.extras!!.getString("KEY_BIRD")!!
photoId = intent.extras!!.getInt("KEY_PHOTO")

birdImageView = findViewById(R.id.activity_bird_info_image)
birdNameView = findViewById(R.id.activity_bird_info_bird_name)
birdEnglishNameView = findViewById(R.id.activity_bird_info_bird_name_english)

birdInfoView = findViewById(R.id.activity_bird_info_text)
actionButton = findViewById(R.id.activity_bird_info_action_button)
playSongButton = findViewById(R.id.activity_bird_info_play_song_button)



birdNameView.text = birdName
// birdEnglishNameView.text = getEnglishName(birdName)
birdImageView.setImageResource(photoId)




}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ class MainActivity : CommonActivity() {
}
}



slider.apply {
itemAdapter.add(
PrimaryDrawerItem().withIdentifier(1).withName("Гид")
Expand Down
14 changes: 11 additions & 3 deletions app/src/main/java/com/deliner/mosfauna/fragment/GuideFragment.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.deliner.mosfauna.fragment

import android.content.Intent
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.os.Message
Expand All @@ -12,6 +13,7 @@ import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import com.deliner.mosfauna.R
import com.deliner.mosfauna.activity.BirdInfoActivity
import com.deliner.mosfauna.dialog.CommonDialogFragment
import com.deliner.mosfauna.dialog.DialogTags
import com.deliner.mosfauna.dialog.PlaceMarkerDialog
Expand Down Expand Up @@ -117,6 +119,10 @@ class GuideFragment : CommonFragment(), OnMapReadyCallback,
override fun handleServiceMessage(msg: Message) {
when (msg.what) {
CoreConst.ON_SEND_MARKER -> sendMarker(currentBirb!!, clickPos!!)
CoreConst.ON_CANCEL_MARKER -> {
currentBirb = null
clickPos = null
}
else -> super.handleServiceMessage(msg)
}
}
Expand All @@ -125,7 +131,6 @@ class GuideFragment : CommonFragment(), OnMapReadyCallback,

}


override fun onCreateDialogEx(tag: String, args: Bundle?): CommonDialogFragment {
return when (tag) {
DialogTags.PLACE_MARKER -> PlaceMarkerDialog.getInstance(args!!.getString("KEY_NAME")!!)
Expand Down Expand Up @@ -158,8 +163,11 @@ class GuideFragment : CommonFragment(), OnMapReadyCallback,
}

override fun onClusterItemInfoWindowClick(item: Bird) {
Toast.makeText(context, "info", Toast.LENGTH_SHORT).show()

val intent = Intent(activity, BirdInfoActivity::class.java)
intent.putExtra("KEY_BIRD", item.name)
intent.putExtra("KEY_PHOTO", item.photo)
startActivity(intent)
// Toast.makeText(context, "info", Toast.LENGTH_SHORT).show()
}

private fun addItems() {
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_baseline_play.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:tint="@color/colorAccent"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,16.5v-9l6,4.5 -6,4.5z" />
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_play.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="32dp" android:tint="?attr/colorControlNormal"
android:viewportHeight="24" android:viewportWidth="24"
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M8,5v14l11,-7z"/>
</vector>
83 changes: 76 additions & 7 deletions app/src/main/res/layout/activity_bird_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,86 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<androidx.constraintlayout.widget.ConstraintLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">

<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
layout="@layout/toolbar" />

<RelativeLayout
android:padding="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">

</androidx.constraintlayout.widget.ConstraintLayout>

<ImageView
android:id="@+id/activity_bird_info_image"
android:layout_width="160dp"
android:layout_height="160dp" />

<LinearLayout
android:id="@+id/activity_bird_info_name_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@+id/activity_bird_info_image"
android:orientation="vertical">

<TextView
android:textSize="24sp"
android:id="@+id/activity_bird_info_bird_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:textSize="18sp"
android:id="@+id/activity_bird_info_bird_name_english"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />


<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/activity_bird_info_bird_play_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Услышать пение птицы " />

<ImageView
android:id="@+id/activity_bird_info_play_song_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/activity_bird_info_bird_play_info"
app:srcCompat="@drawable/ic_baseline_play" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/activity_bird_info_text"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/activity_bird_info_action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_margin="20dp"
android:backgroundTint="@color/colorPrimary"
app:srcCompat="@drawable/ic_play" />
</RelativeLayout>
</LinearLayout>
</androidx.drawerlayout.widget.DrawerLayout>

0 comments on commit 6a543d8

Please sign in to comment.