Skip to content

Instantly share code, notes, and snippets.

View codeamt's full-sized avatar

AnnMargaret Tutu codeamt

View GitHub Profile
Verifying my Blockstack ID is secured with the address 1PKwk23nzAuqWin15Ecst9URHNqoRWxD7r https://explorer.blockstack.org/address/1PKwk23nzAuqWin15Ecst9URHNqoRWxD7r
@codeamt
codeamt / helpers.java
Last active September 28, 2018 04:43
private String makeList(List<String> stuff) {
String merge = "";
for (String s: stuff) {
merge += "- " + s + "\n";
}
return merge;
}
private String edgeCase(String s) {
s = s.equals("") ? getString(R.string.missing_detail) : s;
private void inflateTabs(Sandwich sandwich) {
toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Background"));
tabLayout.addTab(tabLayout.newTab().setText("Ingredients"));
@codeamt
codeamt / Tab2.java
Last active September 26, 2018 06:50
package com.udacity.sandwichclub;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
package com.udacity.sandwichclub;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
package com.udacity.sandwichclub;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
public class PagerAdapter extends FragmentStatePagerAdapter {
int mNumberOfTabs;
public PagerAdapter(FragmentManager fm, int NumberOfTabs) {
private void populateUI(Sandwich model) {
//get text views
TextView nameView = findViewById(R.id.name_tv);
TextView origin = findViewById(R.id.origin_tv);
TextView aka = findViewById(R.id.also_known_tv);
TextView descView = findViewById(R.id.description_tv);
TextView ingredients = findViewById(R.id.ingredients_tv);
//bind data to views
if(model != null) {
package com.udacity.sandwichclub.utils;
import com.udacity.sandwichclub.model.Sandwich;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
package com.udacity.sandwichclub.utils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
public class JsonUtils {
public class JsonUtils {
public static Sandwich parseSandwichJson(String json) {
try {
/* Step One: Convert json string to JSON object */
JSONObject base = new JSONObject(json);
/* Step Two: Parse the Base Object's Keys Into Autonomous Objects/Strings for Serializing */
// Handle anomolies first