use of android.widget.TextView in project glitch-hq-android by tinyspeck.
the class SnapDetailFragment method setSnapDetailView.
protected void setSnapDetailView(View root) {
OnClickListener lsn = new OnClickListener() {
public void onClick(View v) {
String playerId = (String) v.getTag();
ProfileFragment f = new ProfileFragment(m_this, playerId, true);
((HomeScreen) getActivity()).setCurrentFragment(f, true);
}
};
TextView ownerName = (TextView) root.findViewById(R.id.snap_owner_name);
ownerName.setTypeface(m_application.m_vagFont);
ownerName.setText(m_currentSnap.who);
ownerName.setTag(m_currentSnap.playerID);
ownerName.setOnClickListener(lsn);
ImageView goArrow = (ImageView) root.findViewById(R.id.snap_go_arrow);
goArrow.setTag(m_currentSnap.playerID);
goArrow.setOnClickListener(lsn);
ImageView snapPhoto = (ImageView) root.findViewById(R.id.snap_detail_photo);
m_application.Download(m_currentSnap.image, snapPhoto, MyApplication.DOWNLOAD_TYPE_NORMAL);
snapPhoto.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
WebViewFragment f = new WebViewFragment(m_currentSnap.image_orig, "Snap", true);
((HomeScreen) getActivity()).setCurrentFragment(f, true);
}
});
TextView snapDetail = (TextView) root.findViewById(R.id.snap_detail_text);
snapDetail.setText(Html.fromHtml(m_currentSnap.what));
snapDetail.setVisibility((m_currentSnap.what != null && m_currentSnap.what.length() > 0) ? View.VISIBLE : View.GONE);
TextView snapTime = (TextView) root.findViewById(R.id.snap_detail_time);
snapTime.setTypeface(m_application.m_vagLightFont);
snapTime.setText(m_currentSnap.when);
if (!m_currentSnap.when.equalsIgnoreCase("just now"))
snapTime.setText(m_currentSnap.when + " ago");
else
snapTime.setText(m_currentSnap.when);
TextView snapViews = (TextView) root.findViewById(R.id.snap_detail_views);
snapViews.setTypeface(m_application.m_vagLightFont);
if (m_currentSnap.views == 1)
snapViews.setText(String.valueOf(m_currentSnap.views) + " view");
else
snapViews.setText(String.valueOf(m_currentSnap.views) + " views");
EditText snapCommentEditor = (EditText) root.findViewById(R.id.snap_comment_editor);
snapCommentEditor.setHint("Comment on " + m_currentSnap.who + "'s snap...");
snapCommentEditor.setImeActionLabel("Done", EditorInfo.IME_ACTION_DONE);
snapCommentEditor.setImeOptions(EditorInfo.IME_ACTION_DONE);
snapCommentEditor.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE) {
postSnapComment(v.getText().toString());
v.setText("");
InputMethodManager mgr = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
return false;
}
});
LinearLayout snapCommentsView = (LinearLayout) root.findViewById(R.id.snap_comments_view);
if (m_currentSnap.comments != null && m_currentSnap.comments.size() > 0)
snapCommentsView.setVisibility(View.VISIBLE);
else
snapCommentsView.setVisibility(View.GONE);
}
use of android.widget.TextView in project glitch-hq-android by tinyspeck.
the class QuestsFragment method onRequestBack.
@Override
public void onRequestBack(String method, JSONObject response) {
if (method == "quests.getAll") {
JSONArray items = response.optJSONArray("todo");
if (items != null) {
m_questsList.clear();
for (int i = 0; i < items.length(); i++) {
JSONObject item = items.optJSONObject(i);
glitchQuest q = new glitchQuest();
q.title = item.optString("title");
q.desc = item.optString("desc");
JSONObject reqs = item.optJSONObject("reqs");
q.reqs = new Vector<glitchQuestRequirement>();
if (reqs.length() > 0) {
Iterator<String> itr = reqs.keys();
while (itr.hasNext()) {
String key = itr.next();
JSONObject req = reqs.optJSONObject(key);
glitchQuestRequirement qr = new glitchQuestRequirement();
qr.desc = req.optString("desc");
qr.isCount = req.optBoolean("is_count");
qr.completed = req.optBoolean("completed");
qr.gotNum = req.optInt("got_num");
qr.needNum = req.optInt("need_num");
qr.icon = req.optString("icon", null);
q.reqs.add(qr);
}
}
JSONObject rewards = item.optJSONObject("rewards");
q.rewards = new glitchQuestRewards();
q.rewards.favor = new Vector<glitchQuestRewardFavor>();
q.rewards.recipes = new Vector<glitchQuestRewardRecipe>();
q.rewards.imagination = rewards.optInt("xp");
q.rewards.currants = rewards.optInt("currants");
q.rewards.energy = rewards.optInt("energy");
q.rewards.mood = rewards.optInt("mood");
JSONArray favor = rewards.optJSONArray("favor");
if (favor != null) {
for (int j = 0; j < favor.length(); j++) {
JSONObject favorGiant = favor.optJSONObject(j);
glitchQuestRewardFavor fg = new glitchQuestRewardFavor();
fg.giant = favorGiant.optString("giant");
fg.giant = fg.giant.substring(0, 1).toUpperCase() + fg.giant.substring(1);
fg.points = favorGiant.optInt("points");
q.rewards.favor.add(fg);
}
}
JSONArray recipes = rewards.optJSONArray("recipes");
if (recipes != null) {
for (int j = 0; j < recipes.length(); j++) {
JSONObject recipe = recipes.optJSONObject(j);
glitchQuestRewardRecipe r = new glitchQuestRewardRecipe();
r.label = recipe.optString("label");
r.icon = recipe.optString("icon");
q.rewards.recipes.add(r);
}
}
m_questsList.add(q);
}
}
if (m_questsList.size() == 0) {
((TextView) m_root.findViewById(R.id.quests_list_message)).setText("");
}
InitRefreshTimer();
showQuestsPage();
}
onRequestComplete();
}
use of android.widget.TextView in project glitch-hq-android by tinyspeck.
the class QuestsListViewAdapter method createRequirementView.
private View createRequirementView(glitchQuestRequirement req) {
int id = 1;
RelativeLayout holder = new RelativeLayout(m_act);
LinearLayout.LayoutParams holderParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
holderParams.setMargins(10, 0, 0, 0);
holder.setLayoutParams(holderParams);
ImageView icon = new ImageView(m_act);
icon.setId(id++);
RelativeLayout.LayoutParams iconParams = new RelativeLayout.LayoutParams(23, 22);
iconParams.setMargins(2, 0, 0, 5);
iconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
iconParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
icon.setLayoutParams(iconParams);
if (req.icon != null) {
DrawableURL.Show(icon, req.icon, false);
} else {
icon.setImageBitmap(BitmapFactory.decodeResource(m_act.getResources(), R.drawable.quest_requirement));
}
holder.addView(icon, iconParams);
TextView last = new TextView(m_act);
last.setId(id++);
if (req.isCount) {
TextView got = new TextView(m_act);
got.setId(id++);
RelativeLayout.LayoutParams gotParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
gotParams.addRule(RelativeLayout.RIGHT_OF, icon.getId());
gotParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
gotParams.setMargins(4, 0, 0, 0);
got.setLayoutParams(gotParams);
got.setTextAppearance(m_act.getApplicationContext(), R.style.MoodTextStyle);
got.setTypeface(null, Typeface.BOLD);
got.setText(String.valueOf(req.gotNum));
holder.addView(got, gotParams);
RelativeLayout.LayoutParams lastParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lastParams.addRule(RelativeLayout.RIGHT_OF, got.getId());
lastParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
lastParams.setMargins(0, 0, 0, 0);
last.setLayoutParams(lastParams);
last.setTextAppearance(m_act.getApplicationContext(), R.style.MoodTextStyle);
last.setText("/" + String.valueOf(req.needNum));
holder.addView(last, lastParams);
} else {
RelativeLayout.LayoutParams lastParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lastParams.addRule(RelativeLayout.RIGHT_OF, icon.getId());
lastParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
lastParams.setMargins(4, 0, 0, 0);
last.setLayoutParams(lastParams);
last.setTextAppearance(m_act.getApplicationContext(), R.style.MoodTextStyle);
last.setText(req.desc);
holder.addView(last, lastParams);
}
if (req.completed) {
ImageView check = new ImageView(m_act);
RelativeLayout.LayoutParams checkParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
checkParams.addRule(RelativeLayout.ALIGN_LEFT, last.getId());
checkParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
checkParams.setMargins(4, 0, 0, 0);
check.setLayoutParams(checkParams);
check.setImageBitmap(BitmapFactory.decodeResource(m_act.getResources(), R.drawable.checkmark_small));
holder.addView(check, checkParams);
}
return holder;
}
use of android.widget.TextView in project glitch-hq-android by tinyspeck.
the class RecentSnapsFragment method init.
private void init(View root) {
boolean bUpdateData = (m_snapsList == null);
if (bUpdateData) {
m_snapsList = new Vector<glitchSnap>();
}
TextView title = (TextView) root.findViewById(R.id.recent_snaps_title);
title.setTypeface(m_application.m_vagFont);
m_adapter = new RecentSnapsGridViewAdapter(this, m_snapsList);
m_gridView = (GridView) root.findViewById(R.id.recent_snaps_grid);
m_gridView.setAdapter(m_adapter);
if (bUpdateData) {
getRecentSnaps(false);
} else {
showRecentSnapsPage();
}
}
use of android.widget.TextView in project glitch-hq-android by tinyspeck.
the class SettingsFragment method init.
private void init(View root) {
TextView settingsHeader = (TextView) m_root.findViewById(R.id.settings_header);
settingsHeader.setTypeface(m_application.m_vagFont);
TextView pushNotifications = (TextView) m_root.findViewById(R.id.push_notifications);
pushNotifications.setTypeface(m_application.m_vagFont);
TextView termsOfService = (TextView) m_root.findViewById(R.id.terms_of_service);
termsOfService.setTypeface(m_application.m_vagFont);
termsOfService.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
WebViewFragment webview = new WebViewFragment("http://www.glitch.com/terms/", "Settings");
((HomeScreen) getActivity()).setCurrentFragment(webview, true);
}
});
TextView privacyPolicy = (TextView) m_root.findViewById(R.id.privacy_policy);
privacyPolicy.setTypeface(m_application.m_vagFont);
privacyPolicy.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
WebViewFragment webview = new WebViewFragment("http://www.glitch.com/privacy/", "Settings");
((HomeScreen) getActivity()).setCurrentFragment(webview, true);
}
});
TextView communityGuidelines = (TextView) m_root.findViewById(R.id.community_guidelines);
communityGuidelines.setTypeface(m_application.m_vagFont);
communityGuidelines.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
WebViewFragment webview = new WebViewFragment("http://www.glitch.com/guidelines/", "Settings");
((HomeScreen) getActivity()).setCurrentFragment(webview, true);
}
});
TextView settingsLogout = (TextView) m_root.findViewById(R.id.settings_logout);
settingsLogout.setTypeface(m_application.m_vagFont);
settingsLogout.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
((HomeScreen) getActivity()).Logout();
}
});
m_btnNotification = (ToggleButton) m_root.findViewById(R.id.btnNotifications);
m_btnNotification.setChecked(SettingsFragment.getPushNotificationsOption(getActivity()));
m_btnNotification.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
FlurryAgent.logEvent("Settings - 'Notifications' " + arg1);
SettingsFragment.setPushNotificationsOption(getActivity(), arg1);
if (arg1) {
turnOnPushNotifications();
} else {
turnOffPushNotifications();
}
}
});
TextView copyright = (TextView) m_root.findViewById(R.id.settings_copyright);
copyright.setTypeface(m_application.m_vagLightFont);
TextView version = (TextView) m_root.findViewById(R.id.settings_version);
version.setTypeface(m_application.m_vagLightFont);
try {
PackageInfo pInfo = m_application.getPackageManager().getPackageInfo(m_application.getPackageName(), 0);
version.setText("HQ v" + pInfo.versionName);
} catch (NameNotFoundException e) {
version.setText("HQ v1.3");
}
}
Aggregations