Skip to content

Commit 9dca276

Browse files
committed
girl fragment
1 parent 1a621fb commit 9dca276

File tree

9 files changed

+101
-12
lines changed

9 files changed

+101
-12
lines changed

app/src/main/AndroidManifest.xml

+5-6
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,20 @@
1818
<category android:name="android.intent.category.LAUNCHER" />
1919
</intent-filter>
2020
</activity>
21-
<activity android:name=".ui.activity.AboutActivity">
22-
</activity>
23-
24-
21+
<activity android:name=".ui.activity.AboutActivity"></activity>
2522
<activity
2623
android:name="com.airbnb.deeplinkdispatch.DeepLinkActivity"
2724
android:theme="@android:style/Theme.NoDisplay">
2825
<intent-filter>
2926
<action android:name="android.intent.action.VIEW" />
27+
3028
<category android:name="android.intent.category.DEFAULT" />
3129
<category android:name="android.intent.category.BROWSABLE" />
32-
<data android:scheme="gank"/>
33-
</intent-filter>
3430

31+
<data android:scheme="gank" />
32+
</intent-filter>
3533
</activity>
34+
<activity android:name=".ui.activity.ImageActivity"></activity>
3635
</application>
3736

3837
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.wingsofts.gankclient.ui.activity
2+
3+
import android.app.Activity
4+
import android.app.ActivityOptions
5+
import android.content.Context
6+
import android.content.Intent
7+
import android.databinding.DataBindingUtil
8+
import android.support.v7.app.AppCompatActivity
9+
import android.os.Bundle
10+
import android.widget.ImageView
11+
import com.wingsofts.gankclient.R
12+
import com.wingsofts.gankclient.databinding.ActivityImageBinding
13+
14+
class ImageActivity : BaseBindingActivity<ActivityImageBinding>() {
15+
16+
override fun initView() {
17+
mBinding.url = intent.getStringExtra(IMG)
18+
mBinding.root.setOnClickListener { supportFinishAfterTransition() }
19+
}
20+
21+
override fun createDataBinding(savedInstanceState: Bundle?): ActivityImageBinding {
22+
return DataBindingUtil.setContentView(this, R.layout.activity_image)
23+
}
24+
25+
companion object {
26+
val IMG = "IMG"
27+
fun startActivity(context: Context, imageView: ImageView, url: String) {
28+
val intent = Intent(context, ImageActivity::class.java)
29+
intent.putExtra(IMG, url)
30+
context.startActivity(intent,ActivityOptions.makeSceneTransitionAnimation(context as Activity,imageView,"img").toBundle())
31+
}
32+
33+
}
34+
}

app/src/main/java/com/wingsofts/gankclient/ui/adapter/GirlAdapter.kt

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ import com.wingsofts.gankclient.databinding.ItemGirlBinding
1111
* Created by wing on 16-11-25.
1212
*/
1313
class GirlAdapter(private val mList: List<FuckGoods>) : RecyclerView.Adapter<DataBoundViewHolder<ItemGirlBinding>>() {
14+
var mListener: ((pos: Int) -> Unit)? = null
1415
override fun getItemCount(): Int {
1516
return mList.size
1617
}
1718

1819
override fun onBindViewHolder(holder: DataBoundViewHolder<ItemGirlBinding>, position: Int) {
19-
holder.binding.girl = mList[position]
20+
holder.binding.girl = mList[holder.adapterPosition]
21+
22+
holder.binding.root.setOnClickListener {
23+
mListener?.invoke(holder.adapterPosition)
24+
}
2025
holder.binding.executePendingBindings()
2126
}
2227

@@ -25,4 +30,8 @@ class GirlAdapter(private val mList: List<FuckGoods>) : RecyclerView.Adapter<Dat
2530
return DataBoundViewHolder(
2631
ItemGirlBinding.inflate(LayoutInflater.from(parent.context), parent, false))
2732
}
33+
34+
fun setOnItemClickListener(listener: ((pos: Int) -> Unit)) {
35+
mListener = listener
36+
}
2837
}

app/src/main/java/com/wingsofts/gankclient/ui/fragment/GirlFragment.kt

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,27 @@ import android.support.v7.widget.LinearLayoutManager
66
import android.support.v7.widget.RecyclerView
77
import android.view.LayoutInflater
88
import android.view.ViewGroup
9+
import android.widget.ImageView
10+
import com.wingsofts.gankclient.R
911
import com.wingsofts.gankclient.bean.FuckGoods
1012
import com.wingsofts.gankclient.databinding.ViewRecyclerBinding
1113
import com.wingsofts.gankclient.di.component.FuckGoodsModule
1214
import com.wingsofts.gankclient.getMainComponent
1315
import com.wingsofts.gankclient.mvp.contract.FuckGoodsContract
1416
import com.wingsofts.gankclient.mvp.presenter.FuckGoodsPresenter
1517
import com.wingsofts.gankclient.toast
18+
import com.wingsofts.gankclient.ui.activity.ImageActivity
1619
import com.wingsofts.gankclient.ui.adapter.FuckGoodsAdapter
1720
import com.wingsofts.gankclient.ui.adapter.GirlAdapter
21+
import kotlinx.android.synthetic.main.view_recycler.*
1822
import java.util.*
1923
import javax.inject.Inject
2024

2125
/**
2226
* Created by wing on 11/25/16.
2327
*/
2428
class GirlFragment : BaseBingingFragment<ViewRecyclerBinding>(), FuckGoodsContract.View {
25-
29+
private lateinit var mRecyclerView :RecyclerView
2630
private var mList = ArrayList<FuckGoods>()
2731
private lateinit var mAdapter: GirlAdapter
2832
private var mPage = 1
@@ -39,6 +43,7 @@ class GirlFragment : BaseBingingFragment<ViewRecyclerBinding>(), FuckGoodsContra
3943
mAdapter = GirlAdapter(mList)
4044
context.getMainComponent().plus(FuckGoodsModule(this)).inject(this)
4145
with(mBinding!!) {
46+
mRecyclerView = recyclerView
4247
recyclerView.adapter = mAdapter
4348
recyclerView.layoutManager = GridLayoutManager(context,2)
4449
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
@@ -57,6 +62,14 @@ class GirlFragment : BaseBingingFragment<ViewRecyclerBinding>(), FuckGoodsContra
5762
mPresenter.getData(mPage, GIRL)
5863
}
5964

65+
mAdapter.setOnItemClickListener {
66+
pos->
67+
68+
val imageView = recyclerView.findViewHolderForAdapterPosition(pos)?.itemView?.findViewById(R.id.iv_girl) as ImageView
69+
70+
ImageActivity.startActivity(context,imageView,mList[pos].url)
71+
}
72+
6073
}
6174
override fun setData(results: List<FuckGoods>) {
6275

3.19 KB
Loading
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
3+
4+
<data>
5+
6+
<variable
7+
name="url"
8+
type="String" />
9+
</data>
10+
11+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
12+
xmlns:tools="http://schemas.android.com/tools"
13+
android:id="@+id/activity_image"
14+
android:layout_width="match_parent"
15+
android:layout_height="match_parent"
16+
tools:context="com.wingsofts.gankclient.ui.activity.ImageActivity">
17+
18+
<ImageView
19+
android:scaleType="centerCrop"
20+
android:transitionName="img"
21+
android:layout_width="match_parent"
22+
android:layout_height="match_parent"
23+
app:load_image="@{url}" />
24+
</RelativeLayout>
25+
</layout>

app/src/main/res/layout/activity_main.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828

2929
</android.support.design.widget.BottomNavigationView>
3030
<android.support.design.widget.FloatingActionButton
31+
android:src="@drawable/random"
3132
android:id="@+id/floatingButton"
3233
app:layout_behavior="@string/bye_burger_float_behavior"
3334
android:layout_gravity="bottom|right"
3435
app:backgroundTint="@color/colorPrimary"
35-
android:layout_marginBottom="60dp"
36+
android:layout_marginBottom="70dp"
3637
android:layout_marginRight="10dp"
3738
android:layout_width="wrap_content"
3839
android:layout_height="wrap_content"

app/src/main/res/layout/item_fuckgoods.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,24 @@
1111
</data>
1212

1313
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
14+
android:layout_marginLeft="2dp"
15+
android:layout_marginRight="2dp"
1416
android:layout_width="match_parent"
1517
android:layout_height="wrap_content"
1618
android:layout_marginTop="10dp"
1719
android:background="#fff"
1820
android:orientation="vertical"
21+
app:cardCornerRadius="5dp"
1922
android:paddingTop="10dp">
2023

2124
<LinearLayout
2225
android:layout_width="match_parent"
2326
android:layout_height="wrap_content"
2427
android:layout_marginTop="10dp"
2528
android:orientation="vertical"
26-
android:paddingBottom="10dp"
2729
android:paddingLeft="16dp"
30+
android:paddingBottom="10dp"
31+
2832
android:paddingRight="16dp">
2933

3034
<TextView

app/src/main/res/layout/item_girl.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
type="com.wingsofts.gankclient.bean.FuckGoods" />
99
</data>
1010

11-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
11+
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
12+
android:layout_margin="2dp"
1213
android:layout_width="match_parent"
1314
android:layout_height="wrap_content"
15+
app:cardCornerRadius="10dp"
1416
android:orientation="vertical">
1517

1618
<ImageView
19+
android:id="@+id/iv_girl"
20+
android:transitionName="img"
1721
android:scaleType="centerCrop"
1822
app:load_image = "@{girl.url}"
1923
android:layout_width="match_parent"
2024
android:layout_height="200dp" />
21-
</LinearLayout>
25+
</android.support.v7.widget.CardView>
2226
</layout>

0 commit comments

Comments
 (0)