use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class TitledViewPagerActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(getCustomTheme());
KlyphLocale.defineLocale(getBaseContext());
KlyphDevice.initDeviceValues(this, true);
super.onCreate(savedInstanceState);
currentTheme = getCustomTheme();
currentLocale = KlyphLocale.getDeviceLocale();
uiHelper = new UiLifecycleHelper(this, callback);
uiHelper.onCreate(savedInstanceState);
userHasDonated = KlyphPreferences.hasUserDonated();
KlyphDevice.initDeviceValues(this);
setAppIconBackToHomeEnabled(true);
displayBackArrow(true);
getViewPager().setOffscreenPageLimit(3);
setLoadingView(findViewById(R.id.progressBar));
if (!KlyphSession.isLogged()) {
logout();
} else if (Session.getActiveSession() == null) {
Session.openActiveSessionFromCache(this);
}
if (getIntent().getBooleanExtra(KlyphBundleExtras.SET_NOTIFICATION_AS_READ, false) == true) {
String id = getIntent().getStringExtra(KlyphBundleExtras.NOTIFICATION_ID);
if (id != null && id.length() > 0) {
new AsyncRequest(Query.POST_READ_NOTIFICATION, id, "", null).execute();
}
}
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class TitledFragmentActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(getCustomTheme());
KlyphLocale.defineLocale(getBaseContext());
super.onCreate(savedInstanceState);
currentTheme = getCustomTheme();
currentLocale = KlyphLocale.getDeviceLocale();
uiHelper = new UiLifecycleHelper(this, callback);
uiHelper.onCreate(savedInstanceState);
KlyphDevice.initDeviceValues(this);
userHasDonated = KlyphPreferences.hasUserDonated();
if (!(this instanceof MainActivity)) {
setAppIconBackToHomeEnabled(true);
displayBackArrow(true);
} else {
setAppIconBackToHomeEnabled(false);
}
if (!KlyphSession.isLogged()) {
if (!(this instanceof MainActivity))
logout();
} else if (Session.getActiveSession() == null) {
Session.openActiveSessionFromCache(this);
}
if (getIntent().getBooleanExtra(KlyphBundleExtras.SET_NOTIFICATION_AS_READ, false) == true) {
String id = getIntent().getStringExtra(KlyphBundleExtras.NOTIFICATION_ID);
if (id != null && id.length() > 0) {
new AsyncRequest(Query.POST_READ_NOTIFICATION, id, "", null).execute();
}
}
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class StreamButtonBar method delete.
private void delete(View button, final Stream stream) {
final Context context = getContext(button);
final AlertDialog dialog = AlertUtil.showAlert(context, R.string.delete, R.string.deleting);
new AsyncRequest(Query.DELETE_POST, stream.getPost_id(), "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
Log.d("onComplete", "" + response.getError());
dialog.dismiss();
if (response.getError() != null) {
AlertUtil.showAlert(context, R.string.error, R.string.delete_post_error, R.string.ok);
} else {
Toast.makeText(context, R.string.post_deleted, Toast.LENGTH_SHORT).show();
getParentAdapter().remove(stream, true);
}
}
}).execute();
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class ProfileActivity method loadData.
private void loadData() {
isLoading = true;
invalidateOptionsMenu();
new AsyncRequest(getQuery(), id, getQueryParam(), new BaseAsyncRequest.Callback() {
@Override
public void onComplete(final Response response) {
isLoading = false;
if (isDestroyed)
return;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (response.getError() == null) {
onRequestSuccess(response.getGraphObjectList());
} else {
onRequestError(response.getError());
}
invalidateOptionsMenu();
}
});
}
}).execute();
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class AlbumActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_background_transparent_gradient));
getWindow().setBackgroundDrawableResource(R.drawable.image_background);
setTitle("");
setLoadingView(findViewById(R.id.progress_bar));
ArrayList<Photo> photos = getIntent().getParcelableArrayListExtra(KlyphBundleExtras.ALBUM_PHOTOS);
List<String> imageIds = getIntent().getStringArrayListExtra(KlyphBundleExtras.PHOTO_LIST_ID);
if (photos != null) {
List<GraphObject> list = new ArrayList<GraphObject>();
for (Photo photo : photos) {
list.add(photo);
}
((TabsAdapter) getPagerAdapter()).setPhotos(list);
int startPosition = getIntent().getIntExtra(KlyphBundleExtras.START_POSITION, 0);
getViewPager().setCurrentItem(startPosition);
showViewPager();
((TabsAdapter) getPagerAdapter()).show();
setLoadingViewVisible(false);
} else if (imageIds != null) {
String id = "";
int n = imageIds.size();
for (int i = 0; i < n; i++) {
if (i < n - 1) {
id += "\"" + imageIds.get(i) + "\", ";
} else {
id += "\"" + imageIds.get(i) + "\"";
}
}
new AsyncRequest(Query.PHOTO_LIST, id, "", new AsyncRequest.Callback() {
@Override
public void onComplete(final Response response) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (response.getError() == null) {
onPhotoListRequestSuccess(response.getGraphObjectList());
} else {
onPhotoListRequestError(response.getError());
}
}
});
}
}).execute();
} else {
Log.d("AlbumActivity", "else");
String id = getIntent().getStringExtra(KlyphBundleExtras.ALBUM_ID);
// String name =
// getIntent().getStringExtra(CkoobafeBundleExtras.ALBUM_NAME);
// showPageIndicator();
showViewPager();
// ((TabsAdapter) getPagerAdapter()).show();
new AsyncRequest(Query.ALBUM_PHOTOS, id, "", new AsyncRequest.Callback() {
@Override
public void onComplete(final Response response) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (response.getError() == null) {
onAlbumPhotosRequestSuccess(response.getGraphObjectList());
} else {
onAlbumPhotosRequestError(response.getError());
}
}
});
}
}).execute();
}
}
Aggregations