Android Open Source - feeligo_android_sdk Feeligo Sticker Store Activity






From Project

Back to project page feeligo_android_sdk.

License

The source code is released under:

MIT License

If you think the Android project feeligo_android_sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fr.baloomba.feeligo.store;
//  ww w  .j a va2s  . c om
import android.graphics.drawable.Drawable;
import android.os.Bundle;

import android.os.Handler;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;

import com.android.volley.VolleyError;

import fr.baloomba.feeligo.R;
import fr.baloomba.feeligo.helper.ActionBarHelper;
import fr.baloomba.feeligo.helper.FeeligoSettings;
import fr.baloomba.feeligo.model.StickerPack;
import fr.baloomba.feeligo.network.RequestBuilder;

import fr.baloomba.wsvolley.WSStringResponseListener;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

public class FeeligoStickerStoreActivity extends ActionBarActivity {

    // <editor-fold desc="VARIABLES">

    private static final String TAG = FeeligoStickerStoreActivity.class.getSimpleName();

    private Handler mHandler = new Handler();
    private ArrayList<StickerPack> mData;
    private FeeligoStickerStoreAdapter mAdapter = null;

    // </editor-fold>

    // <editor-fold desc="ACTIVITY OVERRIDDEN METHODS">

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sticker_store);

        setActionBar();

        getData();
    }

    @Override
    public void onStart() {
        super.onStart();
        if (mAdapter != null)
            mAdapter.notifyDataSetChanged();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    // </editor-fold>

    // <editor-fold desc="METHODS">

    private void setActionBar() {
        getSupportActionBar().setTitle("Sticker Store");
        getSupportActionBar().setDisplayShowHomeEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        ActionBarHelper.setColor(this, FeeligoSettings.getActiveColor(),
                new Drawable.Callback() {
                    @Override
                    public void invalidateDrawable(Drawable who) {
                        getSupportActionBar().setBackgroundDrawable(who);
                    }

                    @Override
                    public void scheduleDrawable(Drawable who, Runnable what, long when) {
                        mHandler.postAtTime(what, when);
                    }

                    @Override
                    public void unscheduleDrawable(Drawable who, Runnable what) {
                        mHandler.removeCallbacks(what);
                    }
                }
        );
    }

    private void getData() {
        findViewById(R.id.activity_sticker_store_loading_layout).setVisibility(View.VISIBLE);
        mData = new ArrayList<StickerPack>();
        RequestBuilder.getStickerPack(new WSStringResponseListener() {
            @Override
            public void onResponse(String response) {
                try {
                    JSONObject object = new JSONObject(response);
                    JSONArray array = object.getJSONArray("sticker_packs");
                    for (int i = 0; i < array.length(); i++) {
                        mData.add(StickerPack.Factory.getInstance()
                                .stickerPackFromJSON(array.getJSONObject(i)));
                    }
                    setContent();
                } catch (JSONException e) {
                    Log.e(TAG, e.getMessage());
                    findViewById(R.id.activity_sticker_store_loading_layout).setVisibility(View.GONE);
                }
            }

            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e(TAG, error.getMessage());
                findViewById(R.id.activity_sticker_store_loading_layout).setVisibility(View.GONE);
            }
        });
    }

    private void setContent() {
        findViewById(R.id.activity_sticker_store_loading_layout).setVisibility(View.GONE);

        mAdapter = new FeeligoStickerStoreAdapter(this);
        mAdapter.setData(mData);

        ListView listView = ((ListView)findViewById(R.id.activity_sticker_store_list_view));
        listView.setAdapter(mAdapter);
    }

    // </editor-fold>

}




Java Source Code List

fr.baloomba.feeligo.FeeligoKeyboard.java
fr.baloomba.feeligo.FeeligoLog.java
fr.baloomba.feeligo.Feeligo.java
fr.baloomba.feeligo.helper.ActionBarHelper.java
fr.baloomba.feeligo.helper.DisplayHelper.java
fr.baloomba.feeligo.helper.FeeligoHelper.java
fr.baloomba.feeligo.helper.FeeligoLog.java
fr.baloomba.feeligo.helper.FeeligoSettings.java
fr.baloomba.feeligo.helper.JSONHelper.java
fr.baloomba.feeligo.helper.ViewHelper.java
fr.baloomba.feeligo.keyboard.FeeligoKeyboardGridAdapter.java
fr.baloomba.feeligo.keyboard.FeeligoKeyboardListener.java
fr.baloomba.feeligo.keyboard.FeeligoKeyboardPageAdapter.java
fr.baloomba.feeligo.keyboard.FeeligoKeyboardStickerPackPage.java
fr.baloomba.feeligo.model.StickerImage.java
fr.baloomba.feeligo.model.StickerPack.java
fr.baloomba.feeligo.model.Sticker.java
fr.baloomba.feeligo.model.UserStickerPack.java
fr.baloomba.feeligo.network.RequestBuilder.java
fr.baloomba.feeligo.network.URLBuilder.java
fr.baloomba.feeligo.store.FeeligoStickerStoreActivity.java
fr.baloomba.feeligo.store.FeeligoStickerStoreAdapter.java
fr.baloomba.feeligo.store.FeeligoStickerStoreDetailActivity.java
fr.baloomba.feeligo.store.FeeligoStoreDetailAdapter.java
fr.baloomba.feeligo.widget.FeeligoStickerImageView.java
fr.baloomba.feeligo.widget.FeeligoStickerPackTextView.java