Skip to content

Instantly share code, notes, and snippets.

Avatar
💅
coding makes my nails polish peel

Amir A pantos27

💅
coding makes my nails polish peel
View GitHub Profile
@pantos27
pantos27 / MainActivity.java
Created Feb 15, 2016
async task home work
View MainActivity.java
package com.pantos27.www.lesson17_asynctask;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import java.net.URL;
@pantos27
pantos27 / ViewPager.java
Created Sep 29, 2016
Custom Android ViewPager for disabling scrolling with navigation buttons (left/right)
View ViewPager.java
viewPager = new ViewPager(this){
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
View nextFocus = findFocus();
if(event.getAction() == KeyEvent.ACTION_DOWN) {
if(event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT)
Log.d("TestFocus", "" + (nextFocus = FocusFinder.getInstance().findNextFocus(this, findFocus(), FOCUS_RIGHT)));
else if(event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT)
Log.d("TestFocus", "" + (nextFocus = FocusFinder.getInstance().findNextFocus(this, findFocus(), FOCUS_LEFT)));
@pantos27
pantos27 / Activity.java
Created Nov 15, 2016
CircularArrayAdapter, never ending loop list view adapter
View Activity.java
//once created, set the position to the middle
listViewObject.setSelectionFromTop(nameOfAdapterObject.MIDDLE, 0);
@pantos27
pantos27 / read.java
Created Nov 29, 2016
Read\convert an InputStream to a String Java\Android
View read.java
static void openStream(final Context context){
final InputStream stream = context.getResources().openRawResource(R.raw.messages);
String string=convertStreamToString(stream);
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
static String convertStreamToString(java.io.InputStream is) {
View joinArray.java
static <T> T[] joinArrays(T[] first,T[] second){
T[] joined = (T[]) Array.newInstance(second.getClass(),first.length+second.length);
for (int i = 0; i < first.length; i++) {
joined[i] = first[i];
}
for (int i = 0; i < second.length; i++) {
joined[i+first.length] = second[i];
}
@pantos27
pantos27 / hex.java
Created Feb 8, 2017
Hex to byte[] and byte[] to Hex
View hex.java
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
@pantos27
pantos27 / introrx.md
Created Mar 12, 2017 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
View introrx.md
@pantos27
pantos27 / Feed.java
Created Mar 22, 2017
RSS feed object with SimpleXML
View Feed.java
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
import java.util.List;
@Root(name = "channel",strict = false)
class Feed {
@Element(name = "channel")
Channel channel;
@pantos27
pantos27 / CMDProcessor.java
Last active May 17, 2017
SU and SH in Java/Android
View CMDProcessor.java
package com.com.com;
import android.util.Log;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
public class CMDProcessor {