use of io.divide.client.BackendObject in project divide by HiddenStage.
the class BackendObjectAdaper method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
BackendObject user = users.get(position);
ViewHolder holder;
if (convertView != null) {
holder = (ViewHolder) convertView.getTag();
} else {
convertView = inflater.inflate(R.layout.creds_row, parent, false);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
}
holder.name.setText("Key: " + user.getObjectKey());
holder.id.setText("Owner: " + user.getOwnerId());
return convertView;
}
use of io.divide.client.BackendObject in project divide by HiddenStage.
the class MyActivity method getObjects.
@OnClick(R.id.getObjects)
public void getObjects() {
final Query q = new QueryBuilder().select().from(BackendObject.class).limit(10).build();
BackendServices.remote().query(BackendObject.class, q).subscribe(new Action1<Collection<BackendObject>>() {
@Override
public void call(Collection<BackendObject> objects) {
objectList.clear();
objectList.addAll(objects);
adapter.notifyDataSetChanged();
// BackendServices.local().save((BackendObject[]) objects.toArray());
// List<BackendObject> col = BackendServices.local().query(q);
// for (BackendObject o : col) logger.debug(o);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
logger.debug("", throwable);
}
});
}
use of io.divide.client.BackendObject in project divide by HiddenStage.
the class DataManagerTest method testSend.
@Test
public void testSend() throws Exception {
SignUpResponse response = authManager.signUp(new SignUpCredentials("name", "email", ""));
assertEquals(response.get().getUsername(), "name");
BackendServices.remote().save(new BackendObject()).toBlockingObservable();
}
use of io.divide.client.BackendObject in project divide by HiddenStage.
the class MyActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DivideDrawer.attach(this, R.layout.main);
// setContentView(R.layout.main);
ButterKnife.inject(this);
getActionBar().setHomeButtonEnabled(true);
// au = AuthUtils.get(this, AuthManager.ACCOUNT_TYPE); TODO replace this
app = (MyApplication) this.getApplication();
BackendServices.addLoginListener(new LoginListener() {
@Override
public void onNext(BackendUser user) {
System.out.println("loginListener: setUser: " + user);
if (user != null) {
setUser(user);
}
}
});
adapter = new BackendObjectAdaper(this, objectList);
usersLV.setAdapter(adapter);
usersLV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
BackendObject o = adapter.getItem(position);
Query q = new QueryBuilder().delete().from(BackendObject.class).where(TransientObject.OBJECT_KEY, OPERAND.EQ, o.getObjectKey()).build();
BackendServices.remote().query(BackendObject.class, q).subscribe(new Action1<Collection<BackendObject>>() {
@Override
public void call(Collection<BackendObject> backendObjects) {
getObjects();
}
});
BackendServices.local().delete(o);
}
});
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (BackendUser.isLoggedIn())
getObjects();
else
logger.debug("Not signed in, not querying data.");
}
}, 1000);
Storage s = new XmlStorage(new File(this.getFilesDir() + File.separator + "something.xml"), Storage.MODE_WORLD_WRITEABLE);
String id = "something";
System.out.println("Stored: " + s.getString(id, ""));
System.out.println("Stored: " + s.contains(id));
s.edit().putString(id, "something2").commit();
s.edit().putInt("int", 55).commit();
}
Aggregations