Search in sources :

Example 1 with TextButtonItem

use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.

the class TextButtonItemAdapter method mergeViewWithData.

@Override
protected void mergeViewWithData(View view, GraphObject data) {
    TextButtonItemHolder holder = (TextButtonItemHolder) view.getTag();
    TextButtonItem item = (TextButtonItem) data;
    holder.getText().setText(item.getText());
    if (item.getButtonListener() != null) {
        holder.getButton().setOnClickListener(item.getButtonListener());
    }
}
Also used : TextButtonItem(com.abewy.klyph.items.TextButtonItem) TextButtonItemHolder(com.abewy.android.apps.klyph.adapter.holder.TextButtonItemHolder)

Example 2 with TextButtonItem

use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.

the class KlyphDialogFragment method onRequestError.

private void onRequestError(RequestError error) {
    Log.i(TAG, "error " + error.toString());
    if (getView() != null) {
        isError = true;
        loading = false;
        int errorText = this.errorText;
        if (!ConnectionState.getInstance(getActivity()).isOnline()) {
            errorText = R.string.request_connexion_error;
        }
        TextButtonItem errorItem = new TextButtonItem();
        errorItem.setText(getString(errorText));
        // TODO This is not a good copding practice !
        errorItem.setButtonListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                retryRequestAfterError();
            }
        });
        getAdapter().add(errorItem);
        endLoading();
    }
}
Also used : TextButtonItem(com.abewy.klyph.items.TextButtonItem) AbsListView(android.widget.AbsListView) ListEmptyView(com.abewy.android.apps.klyph.view.ListEmptyView) View(android.view.View)

Example 3 with TextButtonItem

use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.

the class KlyphDialogFragment method startLoading.

protected void startLoading() {
    loading = true;
    if (isError == true && getAdapter().getCount() > 0) {
        GraphObject lastObject = getAdapter().getLastItem();
        if (lastObject instanceof TextButtonItem) {
            getAdapter().remove(lastObject);
        }
    }
    isError = false;
    if (!firstLoad) {
        if (!loadingObjectAsFirstItem)
            getAdapter().add(loadingObject);
        else
            getAdapter().insert(loadingObject, 0);
        getAdapter().notifyDataSetChanged();
    }
}
Also used : TextButtonItem(com.abewy.klyph.items.TextButtonItem) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 4 with TextButtonItem

use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.

the class KlyphFragment2 method onRequestNewestError.

private void onRequestNewestError(RequestError error) {
    Log.d("StreamListFragment", "error " + error.toString());
    if (getView() == null || getActivity() == null)
        return;
    int errorText = this.errorNewestText;
    if (!ConnectionState.getInstance(getView().getContext()).isOnline()) {
        errorText = R.string.request_connexion_error;
    }
    TextButtonItem errorItem = new TextButtonItem();
    errorItem.setText(getString(errorText));
    // TODO This is not a good coding practice !
    errorItem.setButtonListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            loadNewest();
        }
    });
    getAdapter().insert(errorItem, 0);
    getAdapter().notifyDataSetChanged();
    mPullToRefreshLayout.setRefreshComplete();
    newestLoading = false;
}
Also used : TextButtonItem(com.abewy.klyph.items.TextButtonItem) ListEmptyView(com.abewy.android.apps.klyph.view.ListEmptyView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) KlyphGridView(com.abewy.android.apps.klyph.widget.KlyphGridView)

Example 5 with TextButtonItem

use of com.abewy.klyph.items.TextButtonItem in project Klyph by jonathangerbaud.

the class KlyphFragment method onRequestError.

private void onRequestError(RequestError error) {
    Log.d(TAG, "error " + error.toString());
    if (getView() == null || getListView() == null)
        return;
    isError = true;
    loading = false;
    int errorText = this.errorText;
    if (!ConnectionState.getInstance(getActivity()).isOnline()) {
        errorText = R.string.request_connexion_error;
    }
    // Fragment can be destroyed but receive the error
    if (getAdapter() != null) {
        if (getAdapter().isEmpty()) {
            setEmptyText(errorText);
            populate(new ArrayList<GraphObject>());
        } else {
            TextButtonItem errorItem = new TextButtonItem();
            errorItem.setText(getString(errorText));
            // TODO This is not a good coding practice !
            errorItem.setButtonListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    retryRequestAfterError();
                }
            });
            getAdapter().add(errorItem);
            endLoading();
        }
    }
}
Also used : TextButtonItem(com.abewy.klyph.items.TextButtonItem) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) KlyphListView(com.abewy.android.apps.klyph.widget.KlyphListView) ListEmptyView(com.abewy.android.apps.klyph.view.ListEmptyView) View(android.view.View) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView)

Aggregations

TextButtonItem (com.abewy.klyph.items.TextButtonItem)11 View (android.view.View)5 AbsListView (android.widget.AbsListView)5 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)5 ListEmptyView (com.abewy.android.apps.klyph.view.ListEmptyView)5 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 Response (com.abewy.android.apps.klyph.core.request.Response)2 AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)2 KlyphGridView (com.abewy.android.apps.klyph.widget.KlyphGridView)2 KlyphListView (com.abewy.android.apps.klyph.widget.KlyphListView)2 TextButtonItemHolder (com.abewy.android.apps.klyph.adapter.holder.TextButtonItemHolder)1