-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf15dfc
commit 281dc1a
Showing
11 changed files
with
521 additions
and
41 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
This file was deleted.
Oops, something went wrong.
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,40 @@ | ||
package com.leo | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.databinding.DataBindingUtil | ||
import com.leo.databinding.ActivityMainBinding | ||
import com.leo.loadingview.MainLoadingActivity | ||
|
||
/** | ||
* 首页展示 | ||
*/ | ||
class MainActivity : AppCompatActivity() { | ||
var mBinding: ActivityMainBinding? = null | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main) | ||
mBinding?.run { | ||
//ShadowLayout的使用 | ||
ShadowLayoutShadow.setOnClickListener { | ||
startActivity(Intent(this@MainActivity, ShadowActivity::class.java)) | ||
} | ||
|
||
ShadowLayoutShape.setOnClickListener { | ||
startActivity(Intent(this@MainActivity, ShapeActivity::class.java)) | ||
} | ||
|
||
ShadowLayoutWiki.setOnClickListener { | ||
startActivity(Intent(this@MainActivity, WikiActivity::class.java)) | ||
} | ||
|
||
//3.4.1 SmartLoadingView的使用 | ||
smartFullscreenAuto.setOnClickListener { | ||
smartFullscreenAuto.startLoading() | ||
smartFullscreenAuto.finishLoadingWithFullScreen(this@MainActivity, MainLoadingActivity::class.java) | ||
} | ||
} | ||
} | ||
} |
159 changes: 159 additions & 0 deletions
159
app/src/main/java/com/leo/loadingview/MainLoadingActivity.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,159 @@ | ||
package com.leo.loadingview | ||
|
||
|
||
import android.os.Bundle | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.databinding.DataBindingUtil | ||
import com.leo.R | ||
import com.leo.databinding.ActivityLoadingMainBinding | ||
|
||
|
||
class MainLoadingActivity : AppCompatActivity() { | ||
private lateinit var mBinding: ActivityLoadingMainBinding | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_loading_main) | ||
supportActionBar?.title = "SmartLoadingView的使用" | ||
// | ||
mBinding.run { | ||
/** | ||
* 1.smart_full_screen:全屏 | ||
* 不支持关注模式 | ||
* */ | ||
|
||
//finishLoadingWithFullScreen 的使用 | ||
smartFullscreenAuto.setOnClickListener { | ||
//1.1、开始加载 | ||
smartFullscreenAuto.startLoading() | ||
|
||
//1.2、模拟2s后,加载成功并跳转(finishLoadingWithFullScreen会自动跳转页面并关闭当前页面) | ||
it.postDelayed({ | ||
smartFullscreenAuto.finishLoadingWithFullScreen(this@MainLoadingActivity, SecondActivity::class.java) | ||
//也可以自己处理动画回调 | ||
//smartFullscreenAuto.finishLoading(true) {} | ||
}, 2000) | ||
} | ||
|
||
//模拟失败 | ||
smartFullscreenFail.setOnClickListener { | ||
smartFullscreenFail.startLoading() | ||
it.postDelayed({ | ||
smartFullscreenFail.finishLoading(false) { | ||
Toast.makeText(this@MainLoadingActivity,"加载失败",Toast.LENGTH_SHORT).show() | ||
} | ||
}, 2000) | ||
} | ||
|
||
|
||
//模拟失败,并展示失败文案 | ||
smartFullscreenFailtxt.setOnClickListener { | ||
smartFullscreenFailtxt.startLoading() | ||
it.postDelayed({ | ||
//smartFullscreenFailtxt.setAnimaledText("我是自定义错误文案") | ||
smartFullscreenFailtxt.finishLoading(false) | ||
}, 2000) | ||
} | ||
|
||
|
||
/** | ||
* 2.smart_button | ||
* 支持关注模式 | ||
* */ | ||
//正常情况下的:"点击关注" 和 "取消关注" | ||
smartButtonSuccess.setOnClickListener { | ||
if (!smartButtonSuccess.isFinished) { | ||
smartButtonSuccess.startLoading() | ||
it.postDelayed({ | ||
//2.1、加载成功--带loading动画的加载成功 | ||
smartButtonSuccess.finishLoading(true) { | ||
Toast.makeText(this@MainLoadingActivity,"关注成功",Toast.LENGTH_SHORT).show() | ||
} | ||
}, 2000) | ||
} else { | ||
//2.2、再次点击,取消关注。通过此方法设置不带动画 | ||
smartButtonSuccess.isFinished = false | ||
} | ||
} | ||
|
||
//模拟关注失败 | ||
smartButtonFail.setOnClickListener { | ||
smartButtonFail.startLoading() | ||
it.postDelayed({ | ||
smartButtonFail.finishLoading(false) { | ||
Toast.makeText(this@MainLoadingActivity,"关注失败,请稍后再试~",Toast.LENGTH_SHORT).show() | ||
} | ||
}, 2000) | ||
} | ||
|
||
//不带动画的 ”关注“ 和 ”取消关注“ | ||
smartButtonNoanimal.setOnClickListener { | ||
smartButtonNoanimal.isFinished = !smartButtonNoanimal.isFinished | ||
} | ||
|
||
|
||
/** | ||
* 3.smart_tick | ||
* 支持关注模式 | ||
* */ | ||
//这里的用法和 smart_button 类似 | ||
smartTickDemo.setOnClickListener { | ||
if (!smartTickDemo.isFinished) { | ||
smartTickDemo.startLoading() | ||
it.postDelayed({ | ||
//2.1、加载成功--带loading动画的加载成功 | ||
smartTickDemo.finishLoading(true) { | ||
Toast.makeText(this@MainLoadingActivity,"关注成功",Toast.LENGTH_SHORT).show() | ||
} | ||
}, 2000) | ||
} else { | ||
//2.2、再次点击,取消关注。通过此方法设置不带动画 | ||
smartTickDemo.isFinished = false | ||
} | ||
} | ||
|
||
|
||
/** | ||
* 4.smart_tick_hide | ||
* 支持关注模式 | ||
* */ | ||
//这里的用法和 smart_button 类似 | ||
smartTickHideDemo.setOnClickListener { | ||
if (!smartTickHideDemo.isFinished) { | ||
smartTickHideDemo.startLoading() | ||
it.postDelayed({ | ||
//2.1、加载成功--带loading动画的加载成功 | ||
smartTickHideDemo.finishLoading(true) { | ||
Toast.makeText(this@MainLoadingActivity,"关注成功",Toast.LENGTH_SHORT).show() | ||
} | ||
}, 2000) | ||
} else { | ||
//2.2、再次点击,取消关注。通过此方法设置不带动画 | ||
smartTickHideDemo.isFinished = false | ||
} | ||
} | ||
|
||
|
||
/** | ||
* 5.smart_tick_center_hide | ||
* 支持关注模式 | ||
* */ | ||
//这里的用法和 smart_button 类似 | ||
smartTickCenterHideDemo.setOnClickListener { | ||
if (!smartTickCenterHideDemo.isFinished) { | ||
smartTickCenterHideDemo.startLoading() | ||
it.postDelayed({ | ||
//2.1、加载成功--带loading动画的加载成功 | ||
smartTickCenterHideDemo.finishLoading(true) { | ||
Toast.makeText(this@MainLoadingActivity,"关注成功",Toast.LENGTH_SHORT).show() | ||
} | ||
}, 2000) | ||
} else { | ||
//2.2、再次点击,取消关注。通过此方法设置不带动画 | ||
smartTickCenterHideDemo.isFinished = false | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
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,20 @@ | ||
package com.leo.loadingview; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.leo.R; | ||
|
||
/** | ||
* Created by leo | ||
* on 2019/5/23. | ||
*/ | ||
public class SecondActivity extends AppCompatActivity { | ||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_second); | ||
} | ||
} |
Oops, something went wrong.