-
-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewriting the fragment to work like in other apps
- Loading branch information
Showing
6 changed files
with
181 additions
and
170 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
35 changes: 35 additions & 0 deletions
35
app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ViewPagerAdapter.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,35 @@ | ||
package com.simplemobiletools.filemanager.pro.adapters | ||
|
||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.viewpager.widget.PagerAdapter | ||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor | ||
import com.simplemobiletools.filemanager.pro.R | ||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity | ||
import com.simplemobiletools.filemanager.pro.extensions.config | ||
import com.simplemobiletools.filemanager.pro.fragments.ItemsFragment | ||
|
||
class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() { | ||
override fun instantiateItem(container: ViewGroup, position: Int): Any { | ||
val layout = getFragment(position) | ||
val view = activity.layoutInflater.inflate(layout, container, false) | ||
container.addView(view) | ||
|
||
(view as ItemsFragment).apply { | ||
setupFragment(activity) | ||
setupColors(activity.config.textColor, activity.getAdjustedPrimaryColor()) | ||
} | ||
|
||
return view | ||
} | ||
|
||
override fun destroyItem(container: ViewGroup, position: Int, item: Any) { | ||
container.removeView(item as View) | ||
} | ||
|
||
override fun getCount() = 1 | ||
|
||
override fun isViewFromObject(view: View, item: Any) = view == item | ||
|
||
private fun getFragment(position: Int) = R.layout.items_fragment | ||
} |
Oops, something went wrong.