Merge pull request #747 from Ullas-Aithal/feature/emptyStateChanges
Added feature to hide progress bar and add an instruction if there are no cards in the list #745 #746
This commit is contained in:
commit
bc0a6f93b1
3 changed files with 72 additions and 4 deletions
|
@ -34,6 +34,8 @@ import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.view.GravityCompat;
|
import androidx.core.view.GravityCompat;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
|
@ -56,6 +58,7 @@ import android.widget.AdapterView;
|
||||||
import android.widget.CheckedTextView;
|
import android.widget.CheckedTextView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.zxing.integration.android.IntentIntegrator;
|
import com.google.zxing.integration.android.IntentIntegrator;
|
||||||
|
@ -114,6 +117,8 @@ public class MainActivity extends BaseActivity
|
||||||
private String filterString;
|
private String filterString;
|
||||||
|
|
||||||
private CountDownTimer countDownTimer;
|
private CountDownTimer countDownTimer;
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
private TextView emptyListView;
|
||||||
|
|
||||||
// QR code scanning
|
// QR code scanning
|
||||||
private void scanQRCode(){
|
private void scanQRCode(){
|
||||||
|
@ -245,8 +250,8 @@ public class MainActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final ProgressBar progressBar = findViewById(R.id.progressBar);
|
progressBar = findViewById(R.id.progressBar);
|
||||||
progressBar.setVisibility(settings.isHideGlobalTimeoutEnabled() ? View.GONE : View.VISIBLE);
|
emptyListView = findViewById(R.id.emptyListView);
|
||||||
|
|
||||||
RecyclerView recList = findViewById(R.id.cardList);
|
RecyclerView recList = findViewById(R.id.cardList);
|
||||||
recList.setHasFixedSize(true);
|
recList.setHasFixedSize(true);
|
||||||
|
@ -256,6 +261,43 @@ public class MainActivity extends BaseActivity
|
||||||
|
|
||||||
tagsDrawerAdapter = new TagsAdapter(this, new HashMap<String, Boolean>());
|
tagsDrawerAdapter = new TagsAdapter(this, new HashMap<String, Boolean>());
|
||||||
adapter = new EntriesCardAdapter(this, tagsDrawerAdapter);
|
adapter = new EntriesCardAdapter(this, tagsDrawerAdapter);
|
||||||
|
adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
||||||
|
@Override
|
||||||
|
public void onChanged() {
|
||||||
|
super.onChanged();
|
||||||
|
hideProgressBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemRangeChanged(int positionStart, int itemCount) {
|
||||||
|
super.onItemRangeChanged(positionStart, itemCount);
|
||||||
|
hideProgressBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemRangeChanged(int positionStart, int itemCount, @Nullable Object payload) {
|
||||||
|
super.onItemRangeChanged(positionStart, itemCount, payload);
|
||||||
|
hideProgressBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemRangeInserted(int positionStart, int itemCount) {
|
||||||
|
super.onItemRangeInserted(positionStart, itemCount);
|
||||||
|
hideProgressBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemRangeRemoved(int positionStart, int itemCount) {
|
||||||
|
super.onItemRangeRemoved(positionStart, itemCount);
|
||||||
|
hideProgressBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
|
||||||
|
super.onItemRangeMoved(fromPosition, toPosition, itemCount);
|
||||||
|
hideProgressBar();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
byte[] encKey = savedInstanceState.getByteArray("encKey");
|
byte[] encKey = savedInstanceState.getByteArray("encKey");
|
||||||
|
@ -898,4 +940,15 @@ public class MainActivity extends BaseActivity
|
||||||
settings.unregisterPreferenceChangeListener(this);
|
settings.unregisterPreferenceChangeListener(this);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* This function will hide the progress bar if the token list is empty along with
|
||||||
|
* showing a view which has instruction on how to add the tokens
|
||||||
|
* */
|
||||||
|
private void hideProgressBar(){
|
||||||
|
int itemCount = adapter.getItemCount();
|
||||||
|
progressBar.setVisibility((settings.isHideGlobalTimeoutEnabled() || itemCount <= 0) ? View.GONE : View.VISIBLE);
|
||||||
|
emptyListView.setVisibility(itemCount > 0 ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -66,7 +66,19 @@
|
||||||
android:paddingTop="@dimen/activity_margin_xsmall"
|
android:paddingTop="@dimen/activity_margin_xsmall"
|
||||||
android:paddingBottom="@dimen/fab_recyclerview_padding"
|
android:paddingBottom="@dimen/fab_recyclerview_padding"
|
||||||
android:clipToPadding="false" />
|
android:clipToPadding="false" />
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingStart="@dimen/activity_margin_large"
|
||||||
|
android:paddingEnd="@dimen/activity_margin_large"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:text="@string/empty_list_view_text"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:gravity="center"
|
||||||
|
tools:visibility="visible"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/emptyListView"/>
|
||||||
<include layout="@layout/component_tags" />
|
<include layout="@layout/component_tags" />
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
|
|
|
@ -114,4 +114,7 @@
|
||||||
<string name="shortcut_name_scan_qr">Scan QR code</string>
|
<string name="shortcut_name_scan_qr">Scan QR code</string>
|
||||||
<string name="shortcut_name_import_qr">Import QR code</string>
|
<string name="shortcut_name_import_qr">Import QR code</string>
|
||||||
<string name="shortcut_name_enter_details">Enter details</string>
|
<string name="shortcut_name_enter_details">Enter details</string>
|
||||||
|
|
||||||
|
<!-- Empty List Text -->
|
||||||
|
<string name="empty_list_view_text">Start adding your tokens by pressing \"+\" at the bottom</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue