use of ingage.ingage.helpers.ThreadsHelper in project iNGAGE by davis123123.
the class PostThreadActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
session = new SessionManager(getApplicationContext());
setContentView(R.layout.activity_post_thread);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
thread = new ThreadsHelper();
rlPage1 = (RelativeLayout) findViewById(R.id.rlPage1);
rlPage2 = (RelativeLayout) findViewById(R.id.rlPage2);
mInsertThreadContent = (EditText) findViewById(R.id.insert_thread_content_text_view);
mInsertThreadTitle = (EditText) findViewById(R.id.insert_thread_title_text_view);
imageToUpload = (ImageView) findViewById(R.id.uploadImageView);
llUploadImage = (LinearLayout) findViewById(R.id.llUploadImage);
btnCategorySpinner = (Button) findViewById(R.id.btnCategorySpinner);
btnNext = (Button) findViewById(R.id.btnNext);
btnSubmit = (Button) findViewById(R.id.btnSubmit);
ivIcon1 = (ImageView) findViewById(R.id.ivIcon1);
ivIcon2 = (ImageView) findViewById(R.id.ivIcon2);
Resources res = getResources();
activeColor = res.getColor(R.color.colorPrimary);
inactiveColor = res.getColor(R.color.gray);
ivIcon1.setColorFilter(activeColor, PorterDuff.Mode.SRC_ATOP);
ivIcon2.setColorFilter(inactiveColor, PorterDuff.Mode.SRC_ATOP);
btnCategorySpinner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FragmentManager fm = getFragmentManager();
f = ListDialogFragment.newInstance();
f.show(fm, "");
}
});
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String threadContent = mInsertThreadContent.getText().toString();
String threadTitle = mInsertThreadTitle.getText().toString();
String cSpinner = (String) btnCategorySpinner.getText();
// USER INSERT
HashMap<String, String> user = session.getUserDetails();
String threadBy = user.get(SessionManager.KEY_NAME);
thread.setThread_title(threadTitle);
thread.setThread_content(threadContent);
thread.setThread_category(cSpinner);
thread.setThread_by(threadBy);
if (threadTitle.length() == 0) {
Toast.makeText(PostThreadActivity.this, "Please provide a title.", Toast.LENGTH_SHORT).show();
return;
}
if (threadContent.length() == 0) {
Toast.makeText(PostThreadActivity.this, "Please provide a description", Toast.LENGTH_SHORT).show();
return;
}
if (btnCategorySpinner.getText().equals(getResources().getString(R.string.category_default)) || btnCategorySpinner.getText() == null) {
Toast.makeText(PostThreadActivity.this, "Please select a category", Toast.LENGTH_SHORT).show();
return;
}
ivIcon2.setColorFilter(activeColor, PorterDuff.Mode.SRC_ATOP);
rlPage1.setVisibility(View.GONE);
rlPage2.setVisibility(View.VISIBLE);
}
});
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String imageTitle = thread.getThread_title().replaceAll("\\s+", "");
// submit image
if (usedImage) {
image = ((BitmapDrawable) imageToUpload.getDrawable()).getBitmap();
image_link = "http://107.170.232.60/images/" + imageTitle + ".JPG";
}
showConfirmationDialog();
}
});
imageToUpload.setVisibility(View.INVISIBLE);
setUploadImageLayout();
llUploadImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
goUploadImage();
}
});
imageToUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
goUploadImage();
}
});
}
use of ingage.ingage.helpers.ThreadsHelper in project iNGAGE by davis123123.
the class SearchResultArchivedFragment 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;
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();
}
checkIfNoThreads(count);
}
use of ingage.ingage.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();
threadTitle = threadsHelper.getThread_title();
String type = "spectate";
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.updateUserRoomSession(thread_id, null, "true");
goToChat(result);
}
}
use of ingage.ingage.helpers.ThreadsHelper in project iNGAGE by davis123123.
the class SearchResultFragment 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_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");
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);
}
Aggregations