Skip to content

Instantly share code, notes, and snippets.

→ bluesm joined (uid13438@gateway/web/irccloud.com/x-vwzagpplvfbnrrfz)
17:06:39 Channel mode is +Ccgnt
17:06:48 ⇐ eulerphi quit ([email protected]) Ping timeout: 252 seconds
17:06:55 <bluesm> I know my question could be vague but I will ask anyway.
17:07:17 <bluesm> Does the "Switch" from enumerable value, will compare and then "jump" or just jump ? It would be not to compare... but just make array with pointers to jump [firstpointer, second pointer, third pointer] and value "0" would select "first pointer" and jump to the first pointer ?
17:07:39 ⇐ haxxpop quit ([email protected]) Quit: Konversation terminated!
17:07:45 <bluesm> Normal switch compares the given value, with other values... But if you have say "3" states. - 0 1 2 - . i could instead of comparing, it could go array of pointers get "n'th" (0 , 1 , 2 in our case) value in this array. And execute something at give pointer.
17:08:46 <bluesm> I know it could depend on the higher programm
package pl.twigit.timertry;
import android.os.Handler;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
public class IdentifyMyParts {
public static int x = 7;
public int y = 3;
}
private int getIntFromEditText (EditText et) throws Exception {
try {
return Integer.parseInt(et.getText().toString());
} catch (Exception e) {
throw new Exception();
}
}
private int getIntFromEditText (EditText et) throws Exception {
try {
return Integer.parseInt(et.getText().toString());
} catch (NumberFormatException e) {
throw e; // because NumberFormatException describe my problem exactly
} catch (Exception e) {
throw e; // every other exception
}
}
private int getIntFromEditText (EditText et) throws NumberFormatException {
return Integer.parseInt(et.getText().toString());
}
private int myMethod () {
try {
someCodeThatCouldThrowException ();
} catch (someCodeThatCouldThrowException's_Exception e) { // pseudocode
throw new myCustomDesigned
}
}
private int myMethod () {
try {
someCodeThatCouldThrowException ();
} catch (someCodeThatCouldThrowException's_Exception e) { // pseudocode
throw new myCustomDesignedExceptionForMyMethod();
}
}
private int myMethod () {
try {
someCodeThatCouldThrowException ();
} catch (someCodeThatCouldThrowException's_Exception e) { // pseudocode
throw new myCustomDesignedExceptionForMyMethod();
}
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
Log.v(MainActivity.TAG, "getView executed");
LayoutInflater layoutInflater = (LayoutInflater)MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View taskRoot = layoutInflater.inflate(R.layout.one_task, null);
((TextView) taskRoot.findViewById(R.id.seconds_edit_text)).setText("00");
((TextView) taskRoot.findViewById(R.id.minutes_edit_text)).setText("00");
((TextView) taskRoot.findViewById(R.id.hours_edit_text)).setText("00");
return taskRoot;