Search in sources :

Example 1 with AsyncRequest

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();
        }
    }
}
Also used : AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) UiLifecycleHelper(com.facebook.UiLifecycleHelper)

Example 2 with AsyncRequest

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();
        }
    }
}
Also used : AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) UiLifecycleHelper(com.facebook.UiLifecycleHelper)

Example 3 with AsyncRequest

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();
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)

Example 4 with AsyncRequest

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();
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) BaseAsyncRequest(com.abewy.android.apps.klyph.core.request.BaseAsyncRequest) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest)

Example 5 with AsyncRequest

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();
    }
}
Also used : AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) ArrayList(java.util.ArrayList) Photo(com.abewy.android.apps.klyph.core.fql.Photo) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) Response(com.abewy.android.apps.klyph.core.request.Response)

Aggregations

AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)37 Response (com.abewy.android.apps.klyph.core.request.Response)34 IFbPermissionCallback (com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)17 AlertDialog (android.app.AlertDialog)9 ArrayList (java.util.ArrayList)6 Bundle (android.os.Bundle)4 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)4 Callback (com.abewy.android.apps.klyph.core.request.BaseAsyncRequest.Callback)4 Context (android.content.Context)3 TagCallback (com.abewy.android.apps.klyph.util.TextViewUtil.TagCallback)3 Intent (android.content.Intent)2 View (android.view.View)2 ImageButton (android.widget.ImageButton)2 TextView (android.widget.TextView)2 Photo (com.abewy.android.apps.klyph.core.fql.Photo)2 TextButtonItem (com.abewy.klyph.items.TextButtonItem)2 UiLifecycleHelper (com.facebook.UiLifecycleHelper)2 Uri (android.net.Uri)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 ViewGroup (android.view.ViewGroup)1