Skip to content

Commit

Permalink
Format sample projects java code with gjf
Browse files Browse the repository at this point in the history
  • Loading branch information
Gautam Korlam committed May 17, 2018
1 parent 47ebc8e commit 36c744f
Show file tree
Hide file tree
Showing 54 changed files with 1,475 additions and 1,509 deletions.
26 changes: 13 additions & 13 deletions another-app/src/com/example/hellojni/HelloJni.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

public class HelloJni {

/* this is used to load the 'hello-jni' library on application
* startup. The library has already been unpacked into
* /data/data/com.example.hellojni/lib/libhello-jni.so at
* installation time by the package manager.
*/
static {
System.loadLibrary("hello-jni");
}
/* this is used to load the 'hello-jni' library on application
* startup. The library has already been unpacked into
* /data/data/com.example.hellojni/lib/libhello-jni.so at
* installation time by the package manager.
*/
static {
System.loadLibrary("hello-jni");
}

/* A native method that is implemented by the
* 'hello-jni' native library, which is packaged
* with this application.
*/
public static native String stringFromJNI();
/* A native method that is implemented by the
* 'hello-jni' native library, which is packaged
* with this application.
*/
public static native String stringFromJNI();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import android.util.AttributeSet;

public class CustomView extends AppCompatTextView {
public CustomView(Context context) {
super(context);
}
public CustomView(Context context) {
super(context);
}

public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public CustomView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public CustomView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,58 @@
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

import com.example.hellojni.HelloJni;
import com.uber.okbuck.example.common.Calc;
import com.uber.okbuck.example.common.CalcMonitor;

public class MainActivity extends AppCompatActivity {

private TextView mTvTest;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

CalcMonitor calcMonitor = new CalcMonitor(this);
calcMonitor.addCalled("from another-app");

mTvTest = findViewById(R.id.mTvTest);
mTvTest.setOnClickListener(v -> mTvTest());
}

void mTvTest() {
Log.d("TEST", "" + android.support.v7.appcompat.R.color.button_material_light);
mTvTest.setText(new StringBuilder().append("1 + 2 = ")
.append(new Calc(new CalcMonitor(this)).add(1, 2))
.append("\n\n")
.append(HelloJni
.stringFromJNI())
.append("\n\n")
.append(getString(
com.uber.okbuck.example.empty.R.string.empty_release_string))
.toString());
private TextView mTvTest;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

CalcMonitor calcMonitor = new CalcMonitor(this);
calcMonitor.addCalled("from another-app");

mTvTest = findViewById(R.id.mTvTest);
mTvTest.setOnClickListener(v -> mTvTest());
}

void mTvTest() {
Log.d("TEST", "" + android.support.v7.appcompat.R.color.button_material_light);
mTvTest.setText(
new StringBuilder()
.append("1 + 2 = ")
.append(new Calc(new CalcMonitor(this)).add(1, 2))
.append("\n\n")
.append(HelloJni.stringFromJNI())
.append("\n\n")
.append(getString(com.uber.okbuck.example.empty.R.string.empty_release_string))
.toString());
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
package com.uber.okbuck.example.test;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static junit.framework.Assert.assertEquals;

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.uber.okbuck.example.MainActivity;
import com.uber.okbuck.example.R;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static junit.framework.Assert.assertEquals;

@RunWith(AndroidJUnit4.class)
public class MainActivityTest {

@Rule
public ActivityTestRule<MainActivity> rule =
new ActivityTestRule(MainActivity.class, true, true);
@Rule
public ActivityTestRule<MainActivity> rule = new ActivityTestRule(MainActivity.class, true, true);

@Test
public void checkTextDisplayed() {
onView(withId(R.id.mTextView2)).check(matches(withText("test in app")));
}
@Test
public void checkTextDisplayed() {
onView(withId(R.id.mTextView2)).check(matches(withText("test in app")));
}

@Test
public void java8LambdaCompilesAndWorksInInstrumentationApk() {
Runnable runnable = () -> assertEquals(3, 2 + 1);
runnable.run();
}
@Test
public void java8LambdaCompilesAndWorksInInstrumentationApk() {
Runnable runnable = () -> assertEquals(3, 2 + 1);
runnable.run();
}
}
6 changes: 3 additions & 3 deletions app/src/demo/java/com/uber/okbuck/example/FlavorLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class FlavorLogger {

public static String log(Context context) {
return "FlavorLogger, dev, " + context.getString(R.string.flavor_string);
}
public static String log(Context context) {
return "FlavorLogger, dev, " + context.getString(R.string.flavor_string);
}
}
6 changes: 3 additions & 3 deletions app/src/dev/java/com/uber/okbuck/example/FlavorLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class FlavorLogger {

public static String log(Context context) {
return "FlavorLogger, dev, " + context.getString(R.string.flavor_string);
}
public static String log(Context context) {
return "FlavorLogger, dev, " + context.getString(R.string.flavor_string);
}
}
27 changes: 13 additions & 14 deletions app/src/main/java/com/uber/okbuck/example/AppShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@

import android.support.multidex.MultiDex;
import android.widget.Toast;

import com.facebook.buck.android.support.exopackage.ExopackageApplication;
import com.uber.okbuck.example.common.Calc;
import com.uber.okbuck.example.common.CalcMonitor;

public class AppShell extends ExopackageApplication {

private static final String APP_NAME = "com.uber.okbuck.example.MyApp";
private final boolean mIsExopackageMode;
private static final String APP_NAME = "com.uber.okbuck.example.MyApp";
private final boolean mIsExopackageMode;

public AppShell() {
super(APP_NAME, BuildConfig.EXOPACKAGE_FLAGS != 0);
mIsExopackageMode = BuildConfig.EXOPACKAGE_FLAGS != 0;
}
public AppShell() {
super(APP_NAME, BuildConfig.EXOPACKAGE_FLAGS != 0);
mIsExopackageMode = BuildConfig.EXOPACKAGE_FLAGS != 0;
}

@Override
protected void onBaseContextAttached() {
if (!mIsExopackageMode) {
MultiDex.install(this);
}
Calc calc = new Calc(new CalcMonitor(this));
Toast.makeText(this, "calc: " + calc.add(1, 2), Toast.LENGTH_SHORT).show();
@Override
protected void onBaseContextAttached() {
if (!mIsExopackageMode) {
MultiDex.install(this);
}
Calc calc = new Calc(new CalcMonitor(this));
Toast.makeText(this, "calc: " + calc.add(1, 2), Toast.LENGTH_SHORT).show();
}
}
Loading

0 comments on commit 36c744f

Please sign in to comment.