Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Farhad Sanaei omegasoft7

  • Germany, Hamburg
Block or report user

Report or block omegasoft7

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@omegasoft7
omegasoft7 / change_strings.gradle
Created Dec 19, 2018
Change String Resources from Gradle
View change_strings.gradle
applicationVariants.all { variant ->
variant.mergeResources.doLast {
def dir = new File("${buildDir}/intermediates/res/merged/${variant.dirName}") //iterating through resources, prepared for including to APK (merged resources)
println("Resources dir " + dir)
dir.eachFileRecurse { file ->
if(file.name.endsWith(".xml")) { //processing only files, which names and with .xml
String content = file.getText('UTF-8')
if(content != null && content.contains("Bill")) {
println("Replacing name in " + file)
content = content.replace("Bill", "Will") //replacing all Bill words with Will word in files
@omegasoft7
omegasoft7 / ExpandableVerticalLinearLayout.java
Created Mar 2, 2016
Make expandable Vertical LinearLayout.Height of view can be wrap content.open/close/toggle can be animated or without animation
View ExpandableVerticalLinearLayout.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
/**
* Created by farhad on 16.2.3.
* this is an expandable linear Layout with orientation of Vertivally
* it will handle whole calculations and animations for height of View
* Your view can have wrap content, it will calculate exact height after adding views to the layout
View createObservable RxJava
public static Observable<String> createObservable(){
return Observable.create((Subscriber<? super String> subscriber) -> {
subscriber.onNext(Thread.currentThread().getName());
subscriber.onCompleted();
}
);
}
@omegasoft7
omegasoft7 / gist:ec2285ae5a873d6f780b
Last active Jan 12, 2018
Change Android Emulator Storage Size
View gist:ec2285ae5a873d6f780b
# Navigate to AVD
cd ~/.android/avd/Nexus5
# Delete old image
#rm userdata-qemu.*
# Re-size the image
e2fsck -f userdata-qemu.img
resize2fs userdata.img 512M
View build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.twitter4j', name: 'twitter4j-core', version: '3.0.2'
}
}
import twitter4j.*
@omegasoft7
omegasoft7 / ActivitySwipeDetector.java
Created Jan 15, 2015
SwipeDetectorIt should set as ontouch event of a View
View ActivitySwipeDetector.java
import android.app.Activity;
import android.view.MotionEvent;
import android.view.View;
public abstract class ActivitySwipeDetector implements View.OnTouchListener {
private Activity activity;
static final int MIN_DISTANCE = 100;
private float downX, downY, upX, upY;
@omegasoft7
omegasoft7 / ScrollView
Created Jan 15, 2015
What we can do to make ScrollView to fill Parent
View ScrollView
Sometimes ScrollView doesn't fill parent 100%. in this case simply just add:
android:fillViewport="true"
to scrollview and that is it. :)
@omegasoft7
omegasoft7 / Logger.java
Created Jan 14, 2015
This is best logger for Android EVER
View Logger.java
public class Logger {
//Variables------------------------------------------------------------------------
private static boolean LOGGING_ENABLED = true;
private static final int STACK_TRACE_LEVELS_UP = 5;
private static String TAG = "YourTag";
@omegasoft7
omegasoft7 / IsAppDebuggable.java
Created Jan 12, 2015
Check if the app is debuggable
View IsAppDebuggable.java
/**
* Returns true if the application is debuggable.
*
* @return true if the application is debuggable.
*/
static boolean isDebuggable() {
PackageManager pm = mApplication.getPackageManager();
try {
return ((pm.getApplicationInfo(mApplication.getPackageName(), 0).flags & ApplicationInfo.FLAG_DEBUGGABLE) > 0);
} catch (NameNotFoundException e) {
View Take Pictures and save
btn01.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent imageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imagesFolder = new File(Environment.getExternalStorageDirectory(), "MyImages");
imagesFolder.mkdirs(); // <----
File image = new File(imagesFolder, "image_001.jpg");
Uri uriSavedImage = Uri.fromFile(image);
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
You can’t perform that action at this time.