-
-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Convert part of java file to kotlin. * Refactoring Indicator. * Optimize Indicator.
- Loading branch information
Showing
46 changed files
with
758 additions
and
725 deletions.
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
26 changes: 0 additions & 26 deletions
26
app/src/main/java/com/example/zhpan/circleviewpager/activity/BaseDataActivity.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/example/zhpan/circleviewpager/activity/BaseDataActivity.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,24 @@ | ||
package com.example.zhpan.circleviewpager.activity | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
|
||
import android.os.Bundle | ||
|
||
import java.util.ArrayList | ||
|
||
abstract class BaseDataActivity : AppCompatActivity() { | ||
|
||
protected var mDrawableList: MutableList<Int> = ArrayList() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
initData() | ||
} | ||
|
||
private fun initData() { | ||
for (i in 0..2) { | ||
val drawable = resources.getIdentifier("guide$i", "drawable", packageName) | ||
mDrawableList.add(drawable) | ||
} | ||
} | ||
} |
92 changes: 0 additions & 92 deletions
92
app/src/main/java/com/example/zhpan/circleviewpager/activity/MainActivity.java
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
app/src/main/java/com/example/zhpan/circleviewpager/activity/MainActivity.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,75 @@ | ||
package com.example.zhpan.circleviewpager.activity | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.viewpager.widget.ViewPager | ||
|
||
|
||
import com.example.zhpan.circleviewpager.R | ||
import com.example.zhpan.circleviewpager.adapter.AdapterFragmentPager | ||
|
||
import kotlinx.android.synthetic.main.activity_main.* | ||
|
||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
initData() | ||
setListener() | ||
} | ||
|
||
private fun initData() { | ||
val mAdapter = AdapterFragmentPager(supportFragmentManager) | ||
vp_fragment!!.adapter = mAdapter | ||
vp_fragment!!.disableTouchScroll(true) | ||
vp_fragment!!.offscreenPageLimit = 2 | ||
vp_fragment!!.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { | ||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { | ||
|
||
} | ||
|
||
override fun onPageSelected(position: Int) { | ||
rg_tab!!.check(getCheckedId(position)) | ||
} | ||
|
||
override fun onPageScrollStateChanged(state: Int) { | ||
|
||
} | ||
}) | ||
} | ||
|
||
private fun getCheckedId(position: Int): Int { | ||
var checkedId = R.id.rb_home | ||
when (position) { | ||
0 -> checkedId = R.id.rb_home | ||
1 -> checkedId = R.id.rb_find | ||
2 -> checkedId = R.id.rb_add | ||
} | ||
return checkedId | ||
} | ||
|
||
private fun setListener() { | ||
rg_tab!!.setOnCheckedChangeListener { group, checkedId -> | ||
if (checkedId == R.id.rb_home) { | ||
vp_fragment!!.setCurrentItem(AdapterFragmentPager.PAGE_HOME, false) | ||
|
||
} else if (checkedId == R.id.rb_find) { | ||
vp_fragment!!.setCurrentItem(AdapterFragmentPager.PAGE_FIND, false) | ||
|
||
} else if (checkedId == R.id.rb_add) { | ||
vp_fragment!!.setCurrentItem(AdapterFragmentPager.PAGE_OTHERS, false) | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
fun start(context: Context) { | ||
context.startActivity(Intent(context, MainActivity::class.java)) | ||
} | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
app/src/main/java/com/example/zhpan/circleviewpager/activity/PhotoViewActivity.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/example/zhpan/circleviewpager/activity/PhotoViewActivity.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,30 @@ | ||
package com.example.zhpan.circleviewpager.activity | ||
|
||
|
||
import android.os.Bundle | ||
|
||
import com.example.zhpan.circleviewpager.R | ||
import com.example.zhpan.circleviewpager.viewholder.PhotoViewHolder | ||
import com.zhpan.bannerview.BannerViewPager | ||
import com.zhpan.bannerview.constants.IndicatorSlideMode | ||
import com.zhpan.bannerview.holder.HolderCreator | ||
|
||
class PhotoViewActivity : BaseDataActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_banner_photo_view) | ||
setTitle(R.string.wrapper_photo_view) | ||
initViewPager() | ||
} | ||
|
||
private fun initViewPager() { | ||
val bannerViewPager = findViewById<BannerViewPager<Int, PhotoViewHolder>>(R.id.viewpager) | ||
bannerViewPager.setAutoPlay(false) | ||
.setCanLoop(false) | ||
.setHolderCreator { PhotoViewHolder() } | ||
.setIndicatorSlideMode(IndicatorSlideMode.SMOOTH) | ||
.create(mDrawableList) | ||
bannerViewPager.currentItem = 1 | ||
} | ||
} |
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
Oops, something went wrong.