Search in sources :

Example 1 with ThreadsHelper

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

the class CategoriesPageFragment method inflateThreads.

void inflateThreads() {
    int count = 0;
    try {
        jsonObject = new JSONObject(json_string);
        jsonArray = jsonObject.getJSONArray("server_response");
        String thread_id, thread_title, thread_content, thread_by, thread_date, thread_category, thread_time_remaining;
        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");
            thread_time_remaining = JO.getString("seconds_remaining");
            long timer = time_remaining(thread_time_remaining);
            ThreadsHelper threadsHelper = new ThreadsHelper(thread_id, thread_title, thread_content, thread_by, thread_date, thread_category, thread_img, timer);
            threadListAdapter.add(threadsHelper);
            threadListAdapter.notifyDataSetChanged();
            count++;
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    checkIfNoThreads(count);
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) ThreadsHelper(ingage.ingage.helpers.ThreadsHelper)

Example 2 with ThreadsHelper

use of ingage.ingage.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();
    threadDescription = threadsHelper.getThread_content();
    Log.i("clicked: ", threadTitle);
    String type = "view";
    chooseSideDialog(context, thread_id, type);
}
Also used : Context(android.content.Context) ThreadsHelper(ingage.ingage.helpers.ThreadsHelper)

Example 3 with ThreadsHelper

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

the class Testadapter method getView.

@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    View row;
    row = convertView;
    ThreadHolder threadHolder;
    if (row == null) {
        LayoutInflater layoutInflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        row = layoutInflater.inflate(R.layout.item_thread_row_layout, parent, false);
        threadHolder = new ThreadHolder();
        threadHolder.thread_title = (TextView) row.findViewById(R.id.thread_title_view);
        row.setTag(threadHolder);
    } else {
        threadHolder = (ThreadHolder) row.getTag();
    }
    ThreadsHelper threadsHelper = (ThreadsHelper) this.getItem(position);
    assert threadsHelper != null;
    threadHolder.thread_title.setText(threadsHelper.getThread_title());
    return row;
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) View(android.view.View) ThreadsHelper(ingage.ingage.helpers.ThreadsHelper) NonNull(android.support.annotation.NonNull)

Example 4 with ThreadsHelper

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

the class ThreadListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof ThreadViewHolder) {
        ThreadsHelper threadsHelper = (ThreadsHelper) this.getItem(position);
        String containImg = threadsHelper.getThread_img();
        // Check if view holder contains an image
        if (containImg.trim().length() == 0) {
            ((ThreadViewHolder) holder).threadImageView.setVisibility(View.GONE);
        } else {
            ((ThreadViewHolder) holder).threadImageView.setVisibility(View.VISIBLE);
            // ((ThreadViewHolder) holder).threadContentTextView.setVisibility(View.GONE);
            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            params.addRule(RelativeLayout.BELOW, R.id.thread_title_view);
            params.setMargins(0, 0, 0, 0);
            ((ThreadViewHolder) holder).threadImageView.setLayoutParams(params);
        }
        // holder.bind(position);
        ThreadViewHolder threadViewHolder = (ThreadViewHolder) holder;
        threadViewHolder.bind(position);
    } else if (holder instanceof LoadingViewHolder) {
        LoadingViewHolder loadingViewHolder = (LoadingViewHolder) holder;
        loadingViewHolder.progressBar.setIndeterminate(true);
    }
}
Also used : RelativeLayout(android.widget.RelativeLayout) ThreadsHelper(ingage.ingage.helpers.ThreadsHelper)

Example 5 with ThreadsHelper

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

the class ArchivedFragment method inflateThreads.

void inflateThreads() {
    int count = 0;
    Log.d("archiveinflate", "clicked");
    try {
        jsonObject = new JSONObject(json_string);
        jsonArray = jsonObject.getJSONArray("server_response");
        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");
            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();
    }
    checkIfNoThreads(count);
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) ThreadsHelper(ingage.ingage.helpers.ThreadsHelper)

Aggregations

ThreadsHelper (ingage.ingage.helpers.ThreadsHelper)9 JSONException (org.json.JSONException)4 JSONObject (org.json.JSONObject)4 View (android.view.View)2 FragmentManager (android.app.FragmentManager)1 Context (android.content.Context)1 Resources (android.content.res.Resources)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 NonNull (android.support.annotation.NonNull)1 LayoutInflater (android.view.LayoutInflater)1 ImageView (android.widget.ImageView)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1 CropImageView (com.theartofdev.edmodo.cropper.CropImageView)1 SpectateRoomHandler (ingage.ingage.handlers.SpectateRoomHandler)1 SessionManager (ingage.ingage.managers.SessionManager)1 HashMap (java.util.HashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1