Skip to content

Commit

Permalink
add TLoadingView's Demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamsiree committed Mar 15, 2020
1 parent 22cd41d commit e44dfd9
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 10 deletions.
3 changes: 2 additions & 1 deletion RxDemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".activity.ActivityTStepperIndicator"></activity>
<activity android:name=".activity.ActivityTLoadingView"></activity>
<activity android:name=".activity.ActivityTStepperIndicator" />
<activity android:name=".activity.ActivityTCardGallery" />
<activity android:name=".activity.ActivityOnCrash" />
<activity android:name=".activity.ActivityTVideoTimeline" />
Expand Down
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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.tamsiree.rxdemo.activity.ActivitySlidingDrawerSingle;
import com.tamsiree.rxdemo.activity.ActivitySplash;
import com.tamsiree.rxdemo.activity.ActivityTCardGallery;
import com.tamsiree.rxdemo.activity.ActivityTLoadingView;
import com.tamsiree.rxdemo.activity.ActivityTStepperIndicator;
import com.tamsiree.rxdemo.activity.ActivityTVideoTimeline;
import com.tamsiree.rxdemo.activity.ActivityTabLayout;
Expand Down Expand Up @@ -145,7 +146,6 @@ public void onRefresh() {
}

private void loadData() {

mSwipeLayout.setRefreshing(true);

if (demo_type == 0) {
Expand All @@ -154,12 +154,10 @@ private void loadData() {
getUIData();
}


if (mDemoList == null || mDemoList.size() <= 0) {
mAdapter.setEmptyView(R.layout.load_data_empty);
}


mSwipeLayout.setRefreshing(false);
}

Expand Down Expand Up @@ -232,6 +230,7 @@ private void getUIData() {
mDemoList.add(new ModelDemo("TabLayout", R.drawable.circle_pocket, ActivityTabLayout.class));
mDemoList.add(new ModelDemo("卡片画廊效果", R.drawable.circle_outlook, ActivityTCardGallery.class));
mDemoList.add(new ModelDemo("步骤指示器", R.drawable.circle_indicator, ActivityTStepperIndicator.class));
mDemoList.add(new ModelDemo("加载中视图", R.drawable.circle_indicator, ActivityTLoadingView.class));
mDemoList.add(new ModelDemo("其他界面效果", R.drawable.circle_icecandy, ActivityOtherEffect.class));
}

Expand Down
94 changes: 94 additions & 0 deletions RxDemo/src/main/res/layout/activity_tloading_view.xml
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>
24 changes: 18 additions & 6 deletions RxDemo/src/main/res/layout/item_recyclerview_main.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ll_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ll_root"
android:paddingStart="0dp"
android:paddingLeft="0dp"
android:paddingEnd="0dp"
Expand All @@ -18,6 +18,15 @@
android:gravity="center_horizontal"
android:orientation="vertical">

<!-- <com.tamsiree.rxui.view.loading.TImageView
android:id="@+id/imageView"
android:layout_width="@dimen/dp_80"
android:layout_height="@dimen/dp_80"
android:padding="@dimen/dp_10"
android:src="@drawable/pikachu_sit"
app:corners="16"
app:gradient="true" />-->

<ImageView
android:id="@+id/imageView"
android:layout_width="@dimen/dp_80"
Expand All @@ -26,17 +35,20 @@
android:padding="@dimen/dp_10"
android:src="@drawable/pikachu_sit" />

<TextView
<com.tamsiree.rxui.view.loading.TTextView
android:id="@+id/tv_name"
android:layout_height="0dp"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="0dp"
android:layout_marginBottom="@dimen/dp_10"
android:layout_weight="1"
android:gravity="center"
android:padding="10dp"
android:text="TextView"
android:textColor="@color/black"
android:textSize="@dimen/sp_12" />
android:textSize="@dimen/sp_12"
app:gradient="true"
app:height_weight="0.8"
app:width_weight="0.6" />

</LinearLayout>

</androidx.cardview.widget.CardView>

0 comments on commit e44dfd9

Please sign in to comment.