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
package com.nkraft.mcusimulator; | |
import com.nkraft.mcusimulator.KeypadModule.OnKeypadClickListener; | |
import com.nkraft.nkraftlibs.Debug; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.Paint; |
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 float[] mSegmentCoords = { | |
103, 56, | |
96, 103, | |
93, 121, | |
86, 170, | |
78, 177, | |
24, 177, | |
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
protected void setModuleInterface(Context context, int resourceImageId) { | |
int screenWidth = context.getResources().getDisplayMetrics().widthPixels; | |
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceImageId); | |
float aspectRatio = bitmap.getWidth() / (float) bitmap.getHeight(); | |
int height = Math.round(screenWidth / aspectRatio); | |
bitmap = Bitmap.createScaledBitmap(bitmap, screenWidth, height, true); | |
BITMAP_WIDTH = bitmap.getWidth(); | |
BITMAP_HEIGHT = bitmap.getHeight(); | |
setBackground(new BitmapDrawable(context.getResources(), bitmap)); | |
} |
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 scaleMatrix(int screenWidth, int screenHeight) { | |
// Title bar height | |
int shift = 100; | |
int maxWidth = 800; | |
int maxHeight = 1280 - shift; | |
int height = screenHeight - ((shift * screenHeight) / maxHeight); | |
float xDpi = getResources().getDisplayMetrics().xdpi; | |
float yDpi = getResources().getDisplayMetrics().xdpi; | |
float density = getResources().getDisplayMetrics().density; |
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 appendLog(String msg) { | |
mLogContent.add(msg); | |
getActivity().runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
String formattedMsg = ""; | |
Iterator<String> iter = mLogContent.iterator(); | |
while( iter.hasNext() ) { | |
String m = iter.next(); | |
formattedMsg += m + "\n"; |
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 FragmentListCommandDialog extends DialogFragment implements OnItemClickListener { | |
public interface CommandClickListener { | |
public void onCommandClick(CommandRow command); | |
} | |
/** | |
* You can found this file in the assets folder | |
*/ | |
private static final String BC_COMMAND_LIST_FILENAME = "bccommands.json"; |
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 int uploadImage(File imageFile) { | |
int serverResponseCode = -1; | |
String fileName = imageFile.getName(); | |
String lineEnd = "\r\n"; | |
String twoHyphens = "--"; | |
String boundary = "*****"; | |
int bytesRead, bytesAvailable, bufferSize; | |
byte[] buffer; |
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 Test { | |
public static void main(String[] args) { | |
Thread t = new Thread(new Executor()); | |
t.start(); | |
System.out.println("I'm from the main thread!"); | |
Thread.sleep(5000); | |
try { | |
System.out.println("Interrupting another thread..."); | |
t.interrupt(); |
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 showSettings() { | |
getFragmentManager() | |
.beginTransaction() | |
.replace(android.R.id.content, new Settings()) | |
.addToBackStack("settings") | |
.commit(); | |
mSettingsShown = true; | |
} | |
private void hideSettings() { |
OlderNewer