Search in sources :

Example 6 with ThreadsHelper

use of ingage.ingage20.helpers.ThreadsHelper in project iNGAGE by davis123123.

the class CategoriesPageFragment method inflateThreads.

void inflateThreads() {
    try {
        jsonObject = new JSONObject(json_string);
        jsonArray = jsonObject.getJSONArray("server_response");
        int count = 0;
        String thread_id, thread_title, thread_content, thread_by, thread_date, thread_category;
        String thread_img_bitmap = null;
        String thread_img = null;
        while (count < jsonArray.length()) {
            JSONObject JO = jsonArray.getJSONObject(count);
            thread_id = JO.getString("thread_id");
            thread_title = JO.getString("thread_title");
            thread_content = JO.getString("thread_content");
            thread_by = JO.getString("thread_by");
            thread_date = JO.getString("thread_date");
            thread_category = JO.getString("thread_category");
            thread_img = JO.getString("thread_image_link");
            /*DownloadImageHandler dlHandler = new DownloadImageHandler(getContext());
                String type = "download";

                //String thread_id = threadsHelper.getThread_id();

                //do conversion
                try {
                    thread_img_bitmap = dlHandler.execute(type, thread_id).get();
                    //Log.d("STATE", "room title: " + threadsHelper.getThread_title());
                    Log.d("STATE", "download thread img result: " + result);
                } catch (InterruptedException | ExecutionException e) {
                    e.printStackTrace();
                }
                Log.d("THREAD_BITMAP","result" + thread_img_bitmap);*/
            ThreadsHelper threadsHelper = new ThreadsHelper(thread_id, thread_title, thread_content, thread_by, thread_date, thread_category, thread_img);
            threadListAdapter.add(threadsHelper);
            threadListAdapter.notifyDataSetChanged();
            count++;
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) ThreadsHelper(ingage.ingage20.helpers.ThreadsHelper)

Example 7 with ThreadsHelper

use of ingage.ingage20.helpers.ThreadsHelper in project iNGAGE by davis123123.

the class FragmentBase method spectate.

public void spectate(int p) {
    ThreadsHelper threadsHelper = (ThreadsHelper) threadListAdapter.getItem(p);
    String thread_id = threadsHelper.getThread_id();
    String type = "spectate";
    session = new SessionManager(getActivity().getApplicationContext());
    HashMap<String, String> user = session.getUserDetails();
    String username = user.get(SessionManager.KEY_NAME);
    SpectateRoomHandler spectateRoomHandler = new SpectateRoomHandler(getActivity().getApplicationContext());
    try {
        // Log.d("JOINSPECTATE", "yes");
        result = spectateRoomHandler.execute(type, thread_id, username).get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    if (result.equals("Spectate room failed")) {
        Toast.makeText(getActivity(), "spectate room failed!", Toast.LENGTH_LONG).show();
    } else {
        chatRoomManager = new ChatRoomManager(getActivity().getApplicationContext());
        chatRoomManager.updateUserRoomSession(thread_id, null, "true");
        goToChat(result);
    }
}
Also used : SpectateRoomHandler(ingage.ingage20.handlers.SpectateRoomHandler) SessionManager(ingage.ingage20.managers.SessionManager) ChatRoomManager(ingage.ingage20.managers.ChatRoomManager) ExecutionException(java.util.concurrent.ExecutionException) ThreadsHelper(ingage.ingage20.helpers.ThreadsHelper)

Example 8 with ThreadsHelper

use of ingage.ingage20.helpers.ThreadsHelper in project iNGAGE by davis123123.

the class FragmentBase method itemClick.

public void itemClick(int p) {
    Context context = getActivity().getApplicationContext();
    if (mToast != null) {
        mToast.cancel();
    }
    ThreadsHelper threadsHelper = (ThreadsHelper) threadListAdapter.getItem(p);
    String thread_id = threadsHelper.getThread_id();
    threadTitle = threadsHelper.getThread_title();
    Log.i("clicked: ", threadTitle);
    // LEAVE UNTIL COMMENTS A RE FINISHED
    // String toastMessage = "Item #" + thread_id + "clicked.";
    // mToast = Toast.makeText(getActivity(), toastMessage, Toast.LENGTH_LONG);
    // mToast.show();
    String type = "view";
    chooseSideDialog(context, thread_id, type);
}
Also used : Context(android.content.Context) ThreadsHelper(ingage.ingage20.helpers.ThreadsHelper)

Example 9 with ThreadsHelper

use of ingage.ingage20.helpers.ThreadsHelper in project iNGAGE by davis123123.

the class FrontPageFragment method inflateThreads.

void inflateThreads() {
    try {
        jsonObject = new JSONObject(json_string);
        jsonArray = jsonObject.getJSONArray("server_response");
        int count = 0;
        String thread_id, thread_title, thread_content, thread_by, thread_date, thread_category;
        String thread_img_bitmap = null;
        String thread_img = null;
        while (count < jsonArray.length()) {
            JSONObject JO = jsonArray.getJSONObject(count);
            thread_id = JO.getString("thread_id");
            thread_title = JO.getString("thread_title");
            thread_content = JO.getString("thread_content");
            thread_by = JO.getString("thread_by");
            thread_date = JO.getString("thread_date");
            thread_category = JO.getString("thread_category");
            thread_img = JO.getString("thread_image_link");
            /* DownloadImageHandler dlHandler = new DownloadImageHandler(getContext());
                String type = "download";

                //String thread_id = threadsHelper.getThread_id();

                //do conversion
                try {
                    thread_img_bitmap = dlHandler.execute(type, thread_id).get();
                    //Log.d("STATE", "room title: " + threadsHelper.getThread_title());
                    Log.d("STATE", "download thread img result: " + result);
                } catch (InterruptedException | ExecutionException e) {
                    e.printStackTrace();
                }
                Log.d("THREAD_BITMAP","result" + thread_img_bitmap);*/
            // thread_img_bitmap = "asdf";
            ThreadsHelper threadsHelper = new ThreadsHelper(thread_id, thread_title, thread_content, thread_by, thread_date, thread_category, thread_img);
            threadListAdapter.add(threadsHelper);
            threadListAdapter.notifyDataSetChanged();
            count++;
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) ThreadsHelper(ingage.ingage20.helpers.ThreadsHelper)

Example 10 with ThreadsHelper

use of ingage.ingage20.helpers.ThreadsHelper in project iNGAGE by davis123123.

the class SearchResultFragment method inflateThreads.

void inflateThreads() {
    try {
        jsonObject = new JSONObject(json_string);
        jsonArray = jsonObject.getJSONArray("server_response");
        int count = 0;
        String thread_id, thread_title, thread_content, thread_by, thread_date, thread_category;
        String thread_img_bitmap = null;
        String thread_img = null;
        while (count < jsonArray.length()) {
            JSONObject JO = jsonArray.getJSONObject(count);
            thread_id = JO.getString("thread_id");
            thread_title = JO.getString("thread_title");
            thread_content = JO.getString("thread_content");
            thread_by = JO.getString("thread_by");
            thread_date = JO.getString("thread_date");
            thread_category = JO.getString("thread_category");
            thread_img = JO.getString("thread_image_link");
            /*DownloadImageHandler dlHandler = new DownloadImageHandler(getContext());
                String type = "download";

                //String thread_id = threadsHelper.getThread_id();

                //do conversion
                try {
                    thread_img_bitmap = dlHandler.execute(type, thread_id).get();
                    //Log.d("STATE", "room title: " + threadsHelper.getThread_title());
                    Log.d("STATE", "download thread img result: " + result);
                } catch (InterruptedException | ExecutionException e) {
                    e.printStackTrace();
                }
                Log.d("THREAD_BITMAP","result" + thread_img_bitmap);*/
            ThreadsHelper threadsHelper = new ThreadsHelper(thread_id, thread_title, thread_content, thread_by, thread_date, thread_category, thread_img);
            threadListAdapter.add(threadsHelper);
            threadListAdapter.notifyDataSetChanged();
            count++;
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) ThreadsHelper(ingage.ingage20.helpers.ThreadsHelper)

Aggregations

ThreadsHelper (ingage.ingage20.helpers.ThreadsHelper)9 JSONException (org.json.JSONException)3 JSONObject (org.json.JSONObject)3 Context (android.content.Context)2 NonNull (android.support.annotation.NonNull)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1 Testadapter (ingage.ingage20.adapters.Testadapter)1 MySQLDbHelper (ingage.ingage20.handlers.MySQLDbHelper)1 SpectateRoomHandler (ingage.ingage20.handlers.SpectateRoomHandler)1 ChatRoomManager (ingage.ingage20.managers.ChatRoomManager)1 SessionManager (ingage.ingage20.managers.SessionManager)1 ExecutionException (java.util.concurrent.ExecutionException)1