1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package cn.flightfeather.thirdapp.module.inspection
 
import android.content.Intent
import android.os.Bundle
import android.support.design.widget.TabLayout
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.view.ViewPager
import cn.flightfeather.thirdapp.CommonApplication
import cn.flightfeather.thirdapp.R
import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo
import cn.flightfeather.thirdapp.module.base.BaseActivity
import cn.flightfeather.thirdapp.module.base.TabViewPagerSetInterface
import kotlinx.android.synthetic.main.activity_share_problem.*
import kotlinx.android.synthetic.main.layout_tab_viewpager.*
 
/**
 * @author riku
 * Date: 2020/5/13
 * 一键分享问题图文
 */
class ShareProblemActivity : BaseActivity(),TabViewPagerSetInterface {
 
    private var problemVoList: List<ProblemlistVo>? = null
 
    private var infoList = arrayListOf<ShareProblemPreViewActivity.Problem>()
 
    override fun getLayoutId(): Int = R.layout.activity_share_problem
 
    @Suppress("UNCHECKED_CAST")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        problemVoList = intent.getSerializableExtra("problemVoList") as List<ProblemlistVo>
        problemVoList?.forEach {vo ->
            val mediaFileList = mutableListOf<Pair<Boolean, String>>()
            vo.mediafileList.forEach {
                mediaFileList.add(Pair(it.ischanged, CommonApplication.getInstance().ROOT_URL_RELEASE_IMAGE + it.extension1 + it.guid + ".jpg"))
            }
 
            infoList.add(ShareProblemPreViewActivity.Problem(
                    vo.sensename, mediaFileList, "${vo.location}${if(vo.problemname ==null) "" else "," + vo.problemname}",
                    vo.advise, "${if (vo.ischanged) getString(R.string.changed) else getString(R.string.unchanged)}${if (vo.changecatalog == null) "" else "," + vo.changecatalog}", vo.time
            ))
        }
        initTab()
        initViewPager()
 
        btn_pass.setOnClickListener {
            val intent = Intent(this, ShareProblemPreViewActivity::class.java)
            intent.putExtra(ShareProblemPreViewActivity.ARG_MERGE_INFO, infoList)
            startActivity(intent)
        }
        btn_fail.setOnClickListener {
            onBackPressed()
        }
    }
 
    override fun getTab(): TabLayout = tab
 
    override fun getViewPager(): ViewPager = view_pager
 
    override fun getTitles(): List<String> {
        val list = mutableListOf<String>()
        for (i in problemVoList?.indices ?: 0..0) {
            list.add("问题${i+1}")
        }
        return list
    }
 
    override fun getTabFragments(): List<Fragment> {
        val list = mutableListOf<Fragment>()
        for (i in problemVoList?.indices ?: 0..0) {
            list.add(ShareProblemFragment.newInstance(infoList[i]))
        }
        return list
    }
 
    override fun getMyFragmentManager(): FragmentManager = supportFragmentManager
}