This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pg = require('pg'); | |
//Optionally, you may have config file that has the parameters used to connect to PG | |
//var config = require('../utilities/config'); | |
var knex = require('knex')({ | |
client: 'pg', | |
connection: { | |
host : '127.0.0.1', | |
port : '5432', | |
user : 'some-role-name', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This utility function is used to prompt the user to give details of the traffic incident | |
*/ | |
public static void renderIncidentReportDialog(final Context appContext){ | |
try{ | |
final Dialog dialog = new Dialog(appContext); | |
dialog.setContentView(R.layout.report_creator_dialog_layout); | |
dialog.setTitle("Traffic Incident Report"); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" > | |
<Spinner | |
android:id="@+id/types_spinner" | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Item{ | |
String entity_id; | |
String attribute_set_id; | |
String type_id; | |
public Item(){} | |
public String getEntityId(){return this.entity_id;} | |
public void setEntityId(String id){this.entity_id = id;} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package za.co.ishlema.blog.examples; | |
import java.io.Serializable; | |
import java.util.UUID; | |
import com.google.gson.Gson; | |
/** | |
* This class represents the user of the app. | |
* Its serialized JSON is stored in the Shared Preferences (if the user elects a 'remember me' option when loging in) | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void getUserLogoutConfirmation(Context context, final SharedPreferences sharedPrefs){ | |
new AlertDialog.Builder(context) | |
.setTitle("Loggin out of IshLema App") | |
.setMessage("Loging out will make the system ask you for username and password next time you use it.") | |
.setPositiveButton("Fine, Forget Me", new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int whichButton) { | |
//remove the cached user | |
try{ | |
Editor sharedPrefsEditor = sharedPrefs.edit(); | |
sharedPrefsEditor.remove(USER_SHAREDPREFERENCE_KEY); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" > | |
<LinearLayout | |
android:id="@+id/loginContainer" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package za.co.ishlema.blog.examples; | |
/** | |
* This is an example of implementing "remember me" login option using SharedPreferences in Android. | |
* @author Ishmael Makitla, | |
* | |
* */ | |
public class LoginActivity extends Activity { | |
private static final String TAG = LoginActivity.class.getSimpleName(); | |
public static final String USER_SHAREDPREFERENCE_KEY = "userPrefKey"; | |
public static final String USER_SHAREDPREFERENCE_VALIDITY_KEY = "valid"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package za.co.ishlema.blog.examples; | |
import java.util.HashMap; | |
import java.util.Map.Entry; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
import android.util.Log; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This object represents JSON string: | |
{ | |
"email" : "[email protected]", | |
"waypoints" : { | |
"-KH9UAPH5NmLJExaUa5g" : { | |
"-KH9UAPH5NmLJExaS2s" : { | |
"latitude" : 111, | |
"longitude" : 111.1 | |
} |
NewerOlder