This file contains 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
@Override | |
protected void onResume() { | |
List<Contact> contacts = getContactsFromYourSource(); | |
ContactsAdapter contactsAdapter = new ContactsAdapter(contacts); | |
contactListView.setAdapter(contactsAdapter); | |
highlightListItem(2); // this simple function call does the trick | |
} | |
private void highlightListItem(int position) { | |
ContactsAdapter contactsAdapter = (ContactsAdapter) contactListView.getAdapter(); |
This file contains 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 clickOnListItem(int position) { | |
contactList.performItemClick(contactListView, position, contactListView.getItemIdAtPosition(position)); | |
} |
This file contains 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 String multipartRequest(String urlTo, String post, String filepath, String filefield) throws ParseException, IOException { | |
HttpURLConnection connection = null; | |
DataOutputStream outputStream = null; | |
InputStream inputStream = null; | |
String twoHyphens = "--"; | |
String boundary = "*****"+Long.toString(System.currentTimeMillis())+"*****"; | |
String lineEnd = "\r\n"; | |
String result = ""; |
This file contains 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 Main { | |
public static void main(String args[]) { | |
String givenString = "ABC ABCDAB ABCDABCDABDE"; | |
String searchedString = "ABCDABD"; | |
int givenStringLetterPosition = 0; | |
int searchedStringLetterPosition = 0; | |
int foundAt = -1; | |
while (givenStringLetterPosition < givenString.length()) { | |
if (givenString.charAt(givenStringLetterPosition) == searchedString.charAt(searchedStringLetterPosition)) { |
This file contains 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 interface SampleView { | |
void displayData(String data); | |
} |
This file contains 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 SampleController { | |
private SampleView view; | |
public SampleController(SampleView view) { | |
this.view = view; | |
} | |
public void generateData() { | |
String generatedData = "Exemplary data generated by controller."; | |
view.displayData(generatedData); |
This file contains 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 SampleActivity extends Activity implements SampleView { | |
@InjectView(R.id.sample_textview) | |
private sampleTextView; | |
private SampleController controller; | |
@Override | |
public displayData(String data) { | |
sampleTextView.setText(data); | |
} |
This file contains 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
function loadJson(callback) { | |
var XmlHttpRequest = new XMLHttpRequest(); | |
XmlHttpRequest.overrideMimeType("application/json"); | |
XmlHttpRequest.open('GET', 'file.json', true); | |
XmlHttpRequest.onreadystatechange = function () { | |
if (XmlHttpRequest.readyState == 4 && XmlHttpRequest.status == "200") { | |
// .open will NOT return a value | |
// but simply returns undefined in async mode so use a callback | |
callback(XmlHttpRequest.responseText); | |
} |
This file contains 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
Original topic: http://stackoverflow.com/questions/7244321/how-to-update-github-forked-repository | |
In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like: | |
# Add the remote, call it "upstream": | |
git remote add upstream https://github.com/whoever/whatever.git | |
# Fetch all the branches of that remote into remote-tracking branches, | |
# such as upstream/master: |
This file contains 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
Gave up waiting for root device. Common problems: | |
- Boot args (cat /proc/cmdline) | |
- Check rootdelay= (did the system wait long enough?) | |
- Check root= (did the system wait for the right device) | |
- Missing modules (cat /proc/modules; ls /dev) | |
ALERT! /dev/disk/by-uuid/96889309-5f73-4688-8354-e64cd1bb158f does not exist. Dropping to a shell! | |
BusyBox v1.21.1 (Ubuntu 1:1.21.0-1ubuntu1) built-in shell (ash) | |
Enter 'help' for a list of build-in commands. |