-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Showing
5 changed files
with
193 additions
and
10 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
77 changes: 77 additions & 0 deletions
77
RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityTLoadingView.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,77 @@ | ||
package com.tamsiree.rxdemo.activity | ||
|
||
import android.annotation.SuppressLint | ||
import android.os.AsyncTask | ||
import android.os.Bundle | ||
import com.tamsiree.rxdemo.R | ||
import com.tamsiree.rxui.activity.ActivityBase | ||
import kotlinx.android.synthetic.main.activity_tloading_view.* | ||
|
||
class ActivityTLoadingView : ActivityBase() { | ||
|
||
private val WAIT_DURATION = 5000 | ||
private var dummyWait: DummyWait? = null | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_tloading_view) | ||
|
||
initView() | ||
|
||
loadData() | ||
} | ||
|
||
private fun initView() { | ||
rxTitle.setLeftFinish(this) | ||
btn_reset.setOnClickListener { resetLoader() } | ||
} | ||
|
||
private fun loadData() { | ||
if (dummyWait != null) { | ||
dummyWait!!.cancel(true) | ||
} | ||
dummyWait = DummyWait() | ||
dummyWait!!.execute() | ||
} | ||
|
||
private fun postLoadData() { | ||
txt_name.text = "神秘商人" | ||
txt_title.text = "只有有缘人能够相遇" | ||
txt_phone.text = "时限 24 小时" | ||
txt_email.text = "说着一口苦涩难懂的语言 ddjhklfsalkjhghjkl" | ||
image_icon.setImageResource(R.drawable.circle_dialog) | ||
} | ||
|
||
private fun resetLoader() { | ||
txt_name.resetLoader() | ||
txt_title.resetLoader() | ||
txt_phone.resetLoader() | ||
txt_email.resetLoader() | ||
image_icon.resetLoader() | ||
loadData() | ||
} | ||
|
||
@SuppressLint("StaticFieldLeak") | ||
internal inner class DummyWait : AsyncTask<Void?, Void?, Void?>() { | ||
|
||
override fun doInBackground(vararg params: Void?): Void? { | ||
try { | ||
Thread.sleep(WAIT_DURATION.toLong()) | ||
} catch (e: InterruptedException) { | ||
e.printStackTrace() | ||
} | ||
return null | ||
} | ||
|
||
override fun onPostExecute(result: Void?) { | ||
super.onPostExecute(result) | ||
postLoadData() | ||
} | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
if (dummyWait != null) { | ||
dummyWait!!.cancel(true) | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<com.tamsiree.rxui.view.RxTitle | ||
android:id="@+id/rxTitle" | ||
android:layout_width="match_parent" | ||
android:layout_height="@dimen/dp_55" | ||
android:background="?colorPrimary" | ||
app:title="加载中视图" /> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/dp_20"> | ||
|
||
<com.tamsiree.rxui.view.loading.TImageView | ||
android:id="@+id/image_icon" | ||
android:layout_width="100dp" | ||
android:layout_height="100dp" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginRight="16dp" | ||
app:corners="16" | ||
app:gradient="true" /> | ||
|
||
<LinearLayout | ||
android:id="@+id/container_text" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_centerVertical="true" | ||
android:layout_toEndOf="@id/image_icon" | ||
android:layout_toRightOf="@id/image_icon" | ||
android:orientation="vertical"> | ||
|
||
<com.tamsiree.rxui.view.loading.TTextView | ||
android:id="@+id/txt_name" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:textSize="@dimen/sp_16" | ||
android:textStyle="bold" | ||
app:gradient="true" | ||
app:height_weight="0.8" | ||
app:width_weight="0.6" /> | ||
|
||
<com.tamsiree.rxui.view.loading.TTextView | ||
android:id="@+id/txt_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:textSize="@dimen/sp_12" | ||
app:corners="32" | ||
app:height_weight="0.8" | ||
app:width_weight="1.0" /> | ||
|
||
<com.tamsiree.rxui.view.loading.TTextView | ||
android:id="@+id/txt_phone" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="4dp" | ||
android:drawablePadding="8dp" | ||
android:textSize="@dimen/sp_12" | ||
app:corners="16" | ||
app:height_weight="0.8" | ||
app:width_weight="0.4" /> | ||
|
||
<com.tamsiree.rxui.view.loading.TTextView | ||
android:id="@+id/txt_email" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="4dp" | ||
android:drawablePadding="8dp" | ||
android:textSize="@dimen/sp_12" | ||
app:TLoadingColor="@color/blue_baby" | ||
app:corners="8" | ||
app:height_weight="0.8" | ||
app:width_weight="0.9" /> | ||
|
||
</LinearLayout> | ||
|
||
</RelativeLayout> | ||
|
||
<Button | ||
android:id="@+id/btn_reset" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/activity_vertical_margin" | ||
android:background="@drawable/shape_round_theme" | ||
android:text="重新加载" | ||
android:textColor="@color/white" /> | ||
|
||
</LinearLayout> |
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