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
import android.app.*; | |
import android.os.*; | |
import android.content.*; | |
public class MyDialog extends DialogFragment { | |
public static final int YES = 1, NO = 0, CANCEL = 2; | |
private String title, message; | |
private OnDismissListener listener; | |
private FragmentManager fragmentManager; |
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
import android.app.*; | |
import android.content.*; | |
import android.os.*; | |
import java.util.*; | |
public class ListDialog extends DialogFragment { | |
private String title; | |
private String[] choices; | |
private OnDismissListener listener; | |
private FragmentManager fragmentManager; |
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
import android.app.*; | |
import android.content.*; | |
import android.os.*; | |
import java.util.*; | |
public class MultiChoiceListDialog extends DialogFragment { | |
private String title; | |
private String[] choices; | |
private ArrayList<String> selectedItems; | |
private OnDismissListener listener; |
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
import android.content.res.*; | |
import java.util.*; | |
import android.content.*; | |
public class InnerReader | |
{ | |
public static String readText(Context context, int resId){ | |
StringBuilder sb = new StringBuilder(); | |
Scanner reader = new Scanner(context.getResources().openRawResource(resId)); |
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
import android.support.design.widget.Snackbar; | |
import android.view.View; | |
import android.widget.TextView; | |
import android.view.View.OnClickListener; | |
import android.graphics.drawable.Drawable; | |
import android.widget.ImageView; | |
import android.graphics.drawable.Icon; | |
import android.graphics.Bitmap; | |
public class Snacker |
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
import android.support.design.widget.Snackbar; | |
import android.view.View; | |
import android.widget.TextView; | |
import android.view.View.OnClickListener; | |
import android.graphics.drawable.Drawable; | |
import android.widget.ImageView; | |
import android.graphics.drawable.Icon; | |
import android.graphics.Bitmap; | |
public class Snacker |
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
/** | |
* This is the simplest method that enables you to pop a notification with a minimum requirement | |
* Remember to add an icon as an icon or a drawable | |
*/ | |
public void popNotification(int notifId, String title, String msg){ | |
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); | |
Notification notif = new Notification.Builder(getBaseContext()) | |
.setSmallIcon(R.drawable.ic_launcher) | |
.setContentTitle(title) |
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 hideKeyboard(View v) { | |
try { | |
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); | |
imm.hideSoftInputFromWindow(v.getWindowToken(), 0); | |
} catch (Exception e) {} | |
} |
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 readText(File file){ | |
StringBuilder builder = new StringBuilder(); | |
try{ | |
Scanner scanner = new Scanner(file); | |
while(scanner.hasNext()){ | |
builder.append(scanner.nextLine()); | |
builder.append('\n'); | |
} | |
scanner.close(); | |
} |
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 bgdrun() { | |
final Handler handler = new Handler(); | |
runOnUiThread(new Runnable(){ | |
@Override | |
public void run() { | |
// update your views here. | |
// do not use loops in here. | |
handler.postDelayed(this, 1000); | |
} | |
}); |