Skip to content

Commit

Permalink
make state a string
Browse files Browse the repository at this point in the history
  • Loading branch information
netimen committed Dec 30, 2015
1 parent 218fca4 commit 00bf074
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 249 deletions.
27 changes: 14 additions & 13 deletions demo/src/main/java/com/bookmate/libs/demo/PlaceholdersActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import android.view.View;
import android.widget.FrameLayout;

import com.bookmate.libs.placeholders.LoaderView;
import com.bookmate.libs.placeholders.LoaderStateView;
import com.bookmate.libs.placeholders.StateView;

import org.androidannotations.annotations.AfterViews;
Expand All @@ -22,7 +22,7 @@
@EActivity(R.layout.activity_placeholders)
public class PlaceholdersActivity extends Activity {
@ViewById
LoaderView loaderView;
LoaderStateView loaderView;

@ViewById
FrameLayout container;
Expand All @@ -32,12 +32,13 @@ public class PlaceholdersActivity extends Activity {

@AfterViews
void ready() {
stateView.showState("t");
stateView.setOnClickListener(new View.OnClickListener() {
public int state;

@Override
public void onClick(View v) {
stateView.showState(++state);
// stateView.showState(++state);
}
});
// EmptyView.setNetworkErrorLogic(new EmptyView.NetworkErrorLogic() {
Expand All @@ -49,31 +50,31 @@ public void onClick(View v) {
// loaderView = new LoaderView(this);
// container.addView(loaderView);

loaderView.setOnRefreshClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
load();
}
});
// loaderView.setOnRefreshClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// load();
// }
// });
}

@Click
void load() {
loaderView.showLoading();
// loaderView.showLoading();
}

@Click
void noData() {
loaderView.showNoData();
// loaderView.showNoData();
}

@Click
void networkError() {
loaderView.showNetworkError(new Exception());
// loaderView.showNetworkError(new Exception());
}

@Click
void serverError() {
loaderView.showNetworkError(new RuntimeException());
// loaderView.showNetworkError(new RuntimeException());
}
}
3 changes: 2 additions & 1 deletion demo/src/main/res/layout/activity_placeholders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:orientation="vertical">

<com.bookmate.libs.placeholders.LoaderView
<com.bookmate.libs.placeholders.LoaderStateView
android:id="@+id/loader_view"
app:iconNoData="@android:drawable/ic_btn_speak_now"
android:layout_width="match_parent"
Expand Down Expand Up @@ -45,6 +45,7 @@
<com.bookmate.libs.placeholders.StateView
android:id="@+id/state_view"
android:layout_gravity="bottom"
app:states="@array/states"
app:statesCaptions="@array/statesCaptions"
app:statesIcons="@array/statesIcons"
android:layout_width="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Copyright (c) 2014 Bookmate.
* All Rights Reserved.
* <p/>
* Author: Dmitry Gordeev <[email protected]>
* Date: 26.06.14
*/
package com.bookmate.libs.placeholders;


import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.FrameLayout;

import com.bookmate.libs.base.anim.FadeAnimator;

public class LoaderStateView extends FrameLayout {

LoadingView loadingView;
StateView stateView;

FadeAnimator fadeAnimator;

public LoaderStateView(Context context) {
super(context);
create(getResources().getInteger(android.R.integer.config_mediumAnimTime));
}

public LoaderStateView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LoaderStateView);
int animationDuration = a.getInt(R.styleable.LoaderStateView_animationDuration, getResources().getInteger(android.R.integer.config_mediumAnimTime));
a.recycle();
create(animationDuration);
// stateView.setParams(StateView.loadAttributes(getContext(), attrs)); // passing attributes to StateView
}

protected void create(int animationDuration) {
fadeAnimator = new FadeAnimator(animationDuration);

inflate(getContext(), R.layout.view_loader, this);
loadingView = (LoadingView) findViewById(R.id.loader_view_loading);
// stateView = (StateView) findViewById(R.id.loader_view_empty);
}

public void showNoData(int noDataTextRes) {
// stateView.getParams().captionNoDataRes = noDataTextRes;
// showNoData();
}

public void hide() {
hide(false);
}

public void hide(boolean animate) {
// state = null;
// uiThreadHelper.hideOnUiThread(animate);
}

public void setLoadingMode() {
loadingView.setLoadingMode(LoadingView.Mode.TEXT);
}

public void setLoadingTextColor(int textColor) {
loadingView.setLoadingTextColor(textColor);
}

public void showState(int state) {
setVisibility(VISIBLE);
// setState(state);
}

}

This file was deleted.

Loading

0 comments on commit 00bf074

Please sign in to comment.