use of com.junjunguo.pocketmaps.fragments.MyAddressAdapter in project PocketMaps by junjunguo.
the class GeocodeActivity method showAddresses.
private RecyclerView showAddresses(final List<Address> list, final boolean viewOnly) {
setContentView(R.layout.activity_addresses);
OnClickAddressListener l = new OnClickAddressListener() {
@Override
public void onClick(Address addr) {
log("Address selected: " + addr);
if (viewOnly) {
GeocodeActivity.backToListViewOnly = true;
GeocodeActivity.backToListData = list;
}
GeocodeActivity.this.finish();
if (callbackListener != null) {
callbackListener.onClick(addr);
}
}
};
OnClickAddressListener detL = new OnClickAddressListener() {
@Override
public void onClick(Address addr) {
log("Address details selected: " + addr);
backToListData = list;
backToListViewOnly = viewOnly;
if (viewOnly) {
GeocodeActivity.this.showAddressDetails(EditType.ViewOnly, addr);
} else {
GeocodeActivity.this.showAddressDetails(EditType.ViewEdit, addr);
}
}
};
MyAddressAdapter adapter = new MyAddressAdapter(list, l, detL);
RecyclerView listView = (RecyclerView) findViewById(R.id.my_addr_recycler_view);
listView.setHasFixedSize(true);
// use a linear layout manager
LinearLayoutManager layoutManager = new LinearLayoutManager(this.getApplicationContext());
layoutManager.setOrientation(RecyclerView.VERTICAL);
listView.setLayoutManager(layoutManager);
listView.setItemAnimator(new DefaultItemAnimator());
listView.setAdapter(adapter);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.my_addr_add_fab);
if (!isFavouritesView()) {
fab.setVisibility(View.INVISIBLE);
} else {
fab.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
log("Plus selected!");
showAddressDetails(EditType.EditOnly, null);
}
});
}
if (!viewOnly) {
addDeleteItemHandler(listView);
}
;
return listView;
}
use of com.junjunguo.pocketmaps.fragments.MyAddressAdapter in project PocketMaps by junjunguo.
the class GeocodeActivity method showAddresses.
private RecyclerView showAddresses(List<Address> list) {
setContentView(R.layout.activity_addresses);
OnClickAddressListener l = new OnClickAddressListener() {
@Override
public void onClick(Address addr) {
log("Address selected: " + addr);
GeocodeActivity.this.finish();
if (callbackListener != null) {
callbackListener.onClick(addr);
}
}
};
MyAddressAdapter adapter = new MyAddressAdapter(list, l);
RecyclerView listView = (RecyclerView) findViewById(R.id.my_addr_recycler_view);
listView.setHasFixedSize(true);
// use a linear layout manager
LinearLayoutManager layoutManager = new LinearLayoutManager(this.getApplicationContext());
layoutManager.setOrientation(LinearLayout.VERTICAL);
listView.setLayoutManager(layoutManager);
listView.setItemAnimator(new DefaultItemAnimator());
listView.setAdapter(adapter);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.my_addr_add_fab);
if (locations == null) {
fab.setVisibility(View.INVISIBLE);
} else {
fab.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
log("Plus selected!");
showFavAdd();
}
});
}
return listView;
}
use of com.junjunguo.pocketmaps.fragments.MyAddressAdapter in project PocketMaps by junjunguo.
the class GeocodeActivity method addDeleteItemHandler.
private void addDeleteItemHandler(RecyclerView recView) {
final MyAddressAdapter recAdapter = (MyAddressAdapter) recView.getAdapter();
OnItemClickListener delL = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Address curAddr = recAdapter.remove(position);
favourites.remove(curAddr.getAddressLine(0));
String mapDir = Variable.getVariable().getMapsFolder().getParent();
String propFile = new File(mapDir, FAV_PROP_FILE).getPath();
try (FileOutputStream fos = new FileOutputStream(propFile)) {
favourites.store(fos, "List of favourites");
} catch (IOException e) {
logUser("Unable to store favourites");
}
}
};
MainActivity.addDeleteItemHandler(this, recView, delL);
}
Aggregations