This commit is contained in:
Christian Basler 2015-10-18 21:47:07 +02:00
parent e8de311d7e
commit ed5fb69eaf
3 changed files with 35 additions and 32 deletions

View File

@ -12,15 +12,6 @@ import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import ch.dissem.apps.abit.listener.ActionBarListener;
import ch.dissem.apps.abit.listener.ListSelectionListener;
import ch.dissem.apps.abit.notification.NetworkNotification;
import ch.dissem.apps.abit.service.Singleton;
import ch.dissem.bitmessage.BitmessageContext;
import ch.dissem.bitmessage.entity.BitmessageAddress;
import ch.dissem.bitmessage.entity.Plaintext;
import ch.dissem.bitmessage.entity.valueobject.Label;
import com.mikepenz.community_material_typeface_library.CommunityMaterial; import com.mikepenz.community_material_typeface_library.CommunityMaterial;
import com.mikepenz.google_material_typeface_library.GoogleMaterial; import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable; import com.mikepenz.iconics.IconicsDrawable;
@ -42,11 +33,10 @@ import org.slf4j.LoggerFactory;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import ch.dissem.apps.abit.listeners.ActionBarListener; import ch.dissem.apps.abit.listener.ActionBarListener;
import ch.dissem.apps.abit.listeners.ListSelectionListener; import ch.dissem.apps.abit.listener.ListSelectionListener;
import ch.dissem.apps.abit.notification.NetworkNotification;
import ch.dissem.apps.abit.service.Singleton; import ch.dissem.apps.abit.service.Singleton;
import ch.dissem.apps.abit.synchronization.Authenticator; import ch.dissem.apps.abit.synchronization.Authenticator;
import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.BitmessageContext;
@ -277,14 +267,7 @@ public class MessageListActivity extends AppCompatActivity
public boolean onItemClick(AdapterView<?> adapterView, View view, int i, long l, IDrawerItem item) { public boolean onItemClick(AdapterView<?> adapterView, View view, int i, long l, IDrawerItem item) {
if (item.getTag() instanceof Label) { if (item.getTag() instanceof Label) {
selectedLabel = (Label) item.getTag(); selectedLabel = (Label) item.getTag();
if (!(getSupportFragmentManager().findFragmentById(R.id.item_list) instanceof MessageListFragment)) { showSelectedLabel();
MessageListFragment listFragment = new MessageListFragment(getApplicationContext());
changeList(listFragment);
listFragment.updateList(selectedLabel);
} else {
((MessageListFragment) getSupportFragmentManager()
.findFragmentById(R.id.item_list)).updateList(selectedLabel);
}
return false; return false;
} else if (item instanceof Nameable<?>) { } else if (item instanceof Nameable<?>) {
Nameable<?> ni = (Nameable<?>) item; Nameable<?> ni = (Nameable<?>) item;
@ -300,6 +283,10 @@ public class MessageListActivity extends AppCompatActivity
case R.string.settings: case R.string.settings:
startActivity(new Intent(MessageListActivity.this, SettingsActivity.class)); startActivity(new Intent(MessageListActivity.this, SettingsActivity.class));
break; break;
case R.string.archive:
selectedLabel = null;
showSelectedLabel();
break;
case R.string.full_node: case R.string.full_node:
return true; return true;
} }
@ -311,6 +298,17 @@ public class MessageListActivity extends AppCompatActivity
.build(); .build();
} }
private void showSelectedLabel() {
if (getSupportFragmentManager().findFragmentById(R.id.item_list) instanceof MessageListFragment) {
((MessageListFragment) getSupportFragmentManager()
.findFragmentById(R.id.item_list)).updateList(selectedLabel);
} else {
MessageListFragment listFragment = new MessageListFragment(getApplicationContext());
changeList(listFragment);
listFragment.updateList(selectedLabel);
}
}
/** /**
* Callback method from {@link ListSelectionListener} * Callback method from {@link ListSelectionListener}
* indicating that the item with the given ID was selected. * indicating that the item with the given ID was selected.
@ -354,6 +352,7 @@ public class MessageListActivity extends AppCompatActivity
@Override @Override
public void updateTitle(CharSequence title) { public void updateTitle(CharSequence title) {
//noinspection ConstantConditions
getSupportActionBar().setTitle(title); getSupportActionBar().setTitle(title);
} }

View File

@ -1,25 +1,24 @@
package ch.dissem.apps.abit; package ch.dissem.apps.abit;
import android.app.Activity; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ListFragment; import android.view.LayoutInflater;
import android.view.*; import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import ch.dissem.apps.abit.listener.ActionBarListener; import ch.dissem.apps.abit.listener.ActionBarListener;
import ch.dissem.apps.abit.listener.ListSelectionListener; import ch.dissem.apps.abit.listener.ListSelectionListener;
import ch.dissem.apps.abit.listeners.ActionBarListener;
import ch.dissem.apps.abit.listeners.ListSelectionListener;
import ch.dissem.apps.abit.service.Singleton; import ch.dissem.apps.abit.service.Singleton;
import ch.dissem.bitmessage.BitmessageContext;
import ch.dissem.bitmessage.entity.BitmessageAddress;
import ch.dissem.bitmessage.entity.Plaintext; import ch.dissem.bitmessage.entity.Plaintext;
import ch.dissem.bitmessage.entity.valueobject.Label; import ch.dissem.bitmessage.entity.valueobject.Label;
import ch.dissem.bitmessage.ports.MessageRepository; import ch.dissem.bitmessage.ports.MessageRepository;
@ -45,6 +44,7 @@ public class MessageListFragment extends AbstractItemListFragment<Plaintext> {
public MessageListFragment() { public MessageListFragment() {
} }
@SuppressLint("ValidFragment")
public MessageListFragment(Context ctx) { public MessageListFragment(Context ctx) {
bmc = Singleton.getBitmessageContext(ctx); bmc = Singleton.getBitmessageContext(ctx);
} }
@ -98,7 +98,11 @@ public class MessageListFragment extends AbstractItemListFragment<Plaintext> {
} }
}); });
if (getActivity() instanceof ActionBarListener) { if (getActivity() instanceof ActionBarListener) {
((ActionBarListener) getActivity()).updateTitle(label.toString()); if (label != null) {
((ActionBarListener) getActivity()).updateTitle(label.toString());
} else {
((ActionBarListener) getActivity()).updateTitle(getString(R.string.archive));
}
} }
if (emptyTrashMenuItem != null) { if (emptyTrashMenuItem != null) {
emptyTrashMenuItem.setVisible(label != null && label.getType() == Label.Type.TRASH); emptyTrashMenuItem.setVisible(label != null && label.getType() == Label.Type.TRASH);

View File

@ -187,7 +187,7 @@ public class AndroidInventory implements Inventory {
"hash = X'" + object.getInventoryVector() + "'", "hash = X'" + object.getInventoryVector() + "'",
null, null, null, null null, null, null, null
); );
return c.getColumnCount() > 0; return c.getCount() > 0;
} }
@Override @Override