Add emptyView

This commit is contained in:
ligi 2015-03-01 17:01:56 +01:00
parent 23238fb593
commit 42b78b9244
3 changed files with 61 additions and 44 deletions

View file

@ -14,12 +14,17 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import com.afollestad.materialdialogs.MaterialDialog;
import com.androidquery.service.MarketService;
import com.melnykov.fab.FloatingActionButton;
import com.squareup.otto.Subscribe;
import fr.nicolaspomepuy.discreetapprate.AppRate;
import fr.nicolaspomepuy.discreetapprate.RetryPolicy;
import org.ligi.axt.AXT;
import org.ligi.passandroid.App;
import org.ligi.passandroid.R;
import org.ligi.passandroid.Tracker;
@ -30,12 +35,6 @@ import org.ligi.passandroid.model.PassStore;
import org.ligi.tracedroid.TraceDroid;
import org.ligi.tracedroid.sending.TraceDroidEmailSender;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import fr.nicolaspomepuy.discreetapprate.AppRate;
import fr.nicolaspomepuy.discreetapprate.RetryPolicy;
public class PassListActivity extends ActionBarActivity {
private PassAdapter passAdapter;
@ -51,14 +50,16 @@ public class PassListActivity extends ActionBarActivity {
@InjectView(R.id.fab)
FloatingActionButton fab;
@InjectView(R.id.emptyView)
TextView emptyView;
@OnClick(R.id.fab)
void onFABClick() {
new MaterialDialog.Builder(this)
.title(getString(R.string.fab_add_dialog_title))
.items(R.array.items)
.itemsCallback( new FABCallback(this))
.negativeText(android.R.string.cancel)
.show();
new MaterialDialog.Builder(this).title(getString(R.string.fab_add_dialog_title))
.items(R.array.items)
.itemsCallback(new FABCallback(this))
.negativeText(android.R.string.cancel)
.show();
}
private NavigationFragment navigationFragment;
@ -89,7 +90,10 @@ public class PassListActivity extends ActionBarActivity {
passStore.refreshPassesList();
passStore.sort(App.getSettings().getSortOrder());
AXT.at(emptyView).setVisibility(passStore.passCount() == 0);
passAdapter.notifyDataSetChanged();
}
});
@ -116,10 +120,7 @@ public class PassListActivity extends ActionBarActivity {
final MarketService ms = new MarketService(this);
ms.level(MarketService.MINOR).checkVersion();
AppRate.with(this)
.retryPolicy(RetryPolicy.EXPONENTIAL)
.initialLaunchCount(5)
.checkAndShow();
AppRate.with(this).retryPolicy(RetryPolicy.EXPONENTIAL).initialLaunchCount(5).checkAndShow();
}
drawerToggle = new ActionBarDrawerToggle(this, drawer, R.string.drawer_open, R.string.drawer_close) {

View file

@ -1,41 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/content_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="@null"
android:listSelector="@android:color/transparent" />
android:id="@+id/content_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="@null"
android:listSelector="@android:color/transparent"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/empty_text_view"
android:singleLine="false"
android:fontFamily="sans-serif"
android:gravity="center"
android:id="@+id/emptyView"
/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_add_white_24dp"
fab:fab_colorNormal="@color/accent"
fab:fab_colorPressed="@color/icon_green"
fab:fab_colorRipple="@color/icon_green" />
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_add_white_24dp"
fab:fab_colorNormal="@color/accent"
fab:fab_colorPressed="@color/icon_green"
fab:fab_colorRipple="@color/icon_green"/>
</FrameLayout>
<FrameLayout
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white" />
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"/>
</android.support.v4.widget.DrawerLayout>

View file

@ -93,4 +93,10 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
<string name="fab_choice_scan_pkpass_files">Scan for pkpass files</string>
<string name="fab_choice_add_demo_pass">Add Demo-Pass</string>
<string name="fab_choice_create_pass">Create Pass (experimental)</string>
<string name="empty_text_view"><big><b>No pass yet</b></big>
\n\n\n You can search your phone for passes
\n\n or create your own
\n\n or try a demo pass
\n\n just press + down below
</string>
</resources>