Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
beiger committed Dec 16, 2018
1 parent 4171b89 commit b2d4529
Show file tree
Hide file tree
Showing 25 changed files with 217 additions and 148 deletions.
8 changes: 3 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.0.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha07'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha08'
implementation "androidx.recyclerview:recyclerview:1.0.0"

// Leakcanary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.2'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
// Optional, if you use support library fragments:
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71"
}
repositories {
mavenCentral()
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.0"
}
6 changes: 6 additions & 0 deletions app/src/main/java/com/bing/mvvmbase/VideoInfoHolder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.bing.mvvmbase

import com.bing.mvvmbase.base.recycleview.BaseViewHolder
import com.bing.mvvmbase.databinding.ItemVideoBinding

class VideoInfoHolder(binding: ItemVideoBinding) : BaseViewHolder<ItemVideoBinding>(binding)
90 changes: 90 additions & 0 deletions app/src/main/res/layout/item_video.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>
<import type="android.view.View" />

<variable
name="selected"
type="Boolean" />

<variable
name="mode"
type="Integer" />
</data>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="231dp">

<LinearLayout
android:id="@+id/backContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">

<ImageView
android:id="@+id/thumb"
android:layout_width="match_parent"
android:layout_height="150dp"
android:scaleType="centerCrop" />

<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="37dp"
android:paddingStart="8dp"
android:singleLine="true"
android:gravity="center_vertical"
android:textSize="16sp"
android:textColor="#ee000000" />

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="36dp">

<ImageView
android:id="@+id/rename"
android:layout_width="48dp"
android:layout_height="36dp"
android:scaleType="centerInside"
android:background="?android:selectableItemBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/delete"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/delete"
android:layout_width="48dp"
android:layout_height="36dp"
android:scaleType="centerInside"
android:background="?android:selectableItemBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/share"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/share"
android:layout_width="48dp"
android:layout_height="36dp"
android:scaleType="centerInside"
android:background="?android:selectableItemBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

<FrameLayout
android:id="@+id/foreground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="@{mode == 0 ? View.GONE : View.VISIBLE}">

</FrameLayout>

</FrameLayout>

</layout>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha02'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10"
}
}

Expand Down
4 changes: 2 additions & 2 deletions mvvmbase/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
implementation 'androidx.multidex:multidex:2.0.0'


implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.0"
implementation 'androidx.core:core:1.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
Expand All @@ -46,7 +46,7 @@ dependencies {
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.0.0'

// navigation
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha07'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha08'

//Paging
implementation 'androidx.paging:paging-runtime:2.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class BaseActivity<DB : ViewDataBinding, VM : BaseViewModel> : AppCompa
bindAndObserve()
}

protected fun onCreateFirst() {
open fun onCreateFirst() {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ abstract class BasePageActivity<DB : ViewDataBinding, VM : BaseViewModel, AD : P
bindAndObserve()
}

protected fun onCreateFirst() {
open fun onCreateFirst() {

}

protected abstract fun initViewModel()
protected abstract fun layoutId(): Int
protected abstract fun initStatusLayout()

protected fun initRefreshLayout() {
open fun initRefreshLayout() {
mRefreshLayout = refreshLayout
mRefreshLayout.setEnableLoadMore(false)
mRefreshLayout.setEnableOverScrollDrag(true)//是否启用越界拖动
Expand All @@ -76,12 +76,12 @@ abstract class BasePageActivity<DB : ViewDataBinding, VM : BaseViewModel, AD : P

protected abstract fun refresh(refreshLayout: RefreshLayout)

protected fun initRefreshHeader() {
open fun initRefreshHeader() {
mClassicsHeader = mRefreshLayout.refreshHeader as ClassicsHeader
mClassicsHeader.setTimeFormat(DynamicTimeFormat(getString(R.string.refresh_at) + " %s"))
}

protected fun initRecycleView() {
open fun initRecycleView() {
mRecyclerView = recyclerView
mRecyclerView.layoutManager = layoutManager
mRecyclerView.itemAnimator = itemAnimator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract class BasePageFragment<DB : ViewDataBinding, VM : BaseViewModel, AVM :

protected abstract fun initStatusLayout()

protected fun initRefreshLayout() {
open fun initRefreshLayout() {
mRefreshLayout = refreshLayout
mRefreshLayout.setEnableLoadMore(false)
mRefreshLayout.setEnableOverScrollDrag(true)//是否启用越界拖动
Expand All @@ -68,12 +68,12 @@ abstract class BasePageFragment<DB : ViewDataBinding, VM : BaseViewModel, AVM :

protected abstract fun refresh(refreshLayout: RefreshLayout)

protected fun initRefreshHeader() {
open fun initRefreshHeader() {
mClassicsHeader = mRefreshLayout.refreshHeader as ClassicsHeader
mClassicsHeader.setTimeFormat(DynamicTimeFormat(getString(R.string.refresh_at) + " %s"))
}

protected fun initRecycleView() {
open fun initRecycleView() {
mRecyclerView = recyclerView
mRecyclerView.layoutManager = layoutManager
mRecyclerView.itemAnimator = itemAnimator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class BasePageViewModel<K, T, TR, DS : BaseDataSource<K, T, TR>, DSF :

protected abstract fun initSourceFactory(): DSF

protected fun initPageConfig(): PagedList.Config {
open fun initPageConfig(): PagedList.Config {
return PagedList.Config.Builder()
.setEnablePlaceholders(false)
.setInitialLoadSizeHint(10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class BasePagedListAdapter<T : IsSame, VH : BaseViewHolder<*>>(private
}

// 在createHolder中使用
protected fun getBinding(parent: ViewGroup, viewType: Int, layoutId: Int): ViewDataBinding {
open fun getBinding(parent: ViewGroup, viewType: Int, layoutId: Int): ViewDataBinding {
return DataBindingUtil.inflate(LayoutInflater.from(parent.context), layoutId, parent, false)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package com.bing.mvvmbase.base.page
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView

class BaseViewHolder<DB : ViewDataBinding>(val binding: DB) : RecyclerView.ViewHolder(binding.root)
open class BaseViewHolder<DB : ViewDataBinding>(val binding: DB) : RecyclerView.ViewHolder(binding.root)
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ abstract class BaseRecycleViewActivity<DB : ViewDataBinding, VM : BaseViewModel,
bindAndObserve()
}

protected fun onCreateFirst() {
open fun onCreateFirst() {

}

protected abstract fun layoutId(): Int
protected abstract fun initStatusLayout()

protected fun initRefreshLayout() {
open fun initRefreshLayout() {
mRefreshLayout = refreshLayout
mRefreshLayout.setEnableLoadMore(false)
mRefreshLayout.setEnableOverScrollDrag(true)//是否启用越界拖动
Expand All @@ -73,12 +73,12 @@ abstract class BaseRecycleViewActivity<DB : ViewDataBinding, VM : BaseViewModel,

protected abstract fun refresh(refreshLayout: RefreshLayout)

protected fun initRefreshHeader() {
open fun initRefreshHeader() {
mClassicsHeader = mRefreshLayout.refreshHeader as ClassicsHeader
mClassicsHeader.setTimeFormat(DynamicTimeFormat(getString(R.string.refresh_at) + " %s"))
}

protected fun initRecycleView() {
open fun initRecycleView() {
mRecyclerView = recyclerView
mRecyclerView.layoutManager = layoutManager
mRecyclerView.itemAnimator = itemAnimator
Expand All @@ -88,7 +88,7 @@ abstract class BaseRecycleViewActivity<DB : ViewDataBinding, VM : BaseViewModel,

protected abstract fun initAdapter()

protected fun bindAndObserve() {
open fun bindAndObserve() {
data.observe(this, Observer { data -> mAdapter.data = data })
networkState.observe(this, Observer { status ->
if (status == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package com.bing.mvvmbase.base.recycleview
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView

class BaseViewHolder<DB : ViewDataBinding>(val binding: DB) : RecyclerView.ViewHolder(binding.root)
open class BaseViewHolder<DB : ViewDataBinding>(val binding: DB) : RecyclerView.ViewHolder(binding.root)
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ abstract class BaseBottomNavigationActivity<DB : ViewDataBinding, VM : BaseViewM
bindAndObserve()
}

protected fun onCreateFirst() {
open fun onCreateFirst() {

}

protected abstract fun layoutId(): Int

protected fun initViewPagerAndBottomNav() {
open fun initViewPagerAndBottomNav() {
mViewPager = viewpager()
mFragmentPagerAdapter = BaseFragmentPagerAdapter(supportFragmentManager, initFragments())
mViewPager.adapter = mFragmentPagerAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter

class BaseFragmentPagerAdapter(fm: FragmentManager, protected var mFragments: List<Fragment>) : FragmentPagerAdapter(fm) {
open class BaseFragmentPagerAdapter(fm: FragmentManager, protected var mFragments: List<Fragment>) : FragmentPagerAdapter(fm) {

override fun getItem(position: Int): Fragment {
return mFragments[position]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter

class BaseFragmentStatePagerAdapter<E>(fm: FragmentManager, protected var mData: List<E>) : FragmentStatePagerAdapter(fm) {
open class BaseFragmentStatePagerAdapter<E>(fm: FragmentManager, protected var mData: List<E>) : FragmentStatePagerAdapter(fm) {

override fun getItem(position: Int): Fragment? {
return null
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.bing.mvvmbase.bindingadapter

import android.view.View
import android.widget.ImageView

import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide

@BindingAdapter("visibleGone")
fun showHide(view: View, show: Boolean) {
view.visibility = if (show) View.VISIBLE else View.GONE
}

@BindingAdapter("img_url")
fun showImg(iv: ImageView, url: String) {
Glide.with(iv.context).load(url).into(iv)
}
Loading

0 comments on commit b2d4529

Please sign in to comment.