Address a few warnings and suggestions for Android sample app
Summary: ^ Reviewed By: LukeDefeo Differential Revision: D39575170 fbshipit-source-id: 8be293fe31521531e634132e4ca454da32aad73f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
84dc95b27b
commit
1fac19facc
@@ -26,66 +26,36 @@ public class AnimationsActivity extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_animations);
|
setContentView(R.layout.activity_animations);
|
||||||
|
|
||||||
btnBlink = (Button) findViewById(R.id.btnBlink);
|
btnBlink = findViewById(R.id.btnBlink);
|
||||||
btnRotate = (Button) findViewById(R.id.btnRotate);
|
btnRotate = findViewById(R.id.btnRotate);
|
||||||
btnMove = (Button) findViewById(R.id.btnMove);
|
btnMove = findViewById(R.id.btnMove);
|
||||||
btnBounce = (Button) findViewById(R.id.btnBounce);
|
btnBounce = findViewById(R.id.btnBounce);
|
||||||
btnSequential = (Button) findViewById(R.id.btnSequential);
|
btnSequential = findViewById(R.id.btnSequential);
|
||||||
txtBlink = (TextView) findViewById(R.id.txt_blink);
|
txtBlink = findViewById(R.id.txt_blink);
|
||||||
txtRotate = (TextView) findViewById(R.id.txt_rotate);
|
txtRotate = findViewById(R.id.txt_rotate);
|
||||||
txtMove = (TextView) findViewById(R.id.txt_move);
|
txtMove = findViewById(R.id.txt_move);
|
||||||
txtBounce = (TextView) findViewById(R.id.txt_bounce);
|
txtBounce = findViewById(R.id.txt_bounce);
|
||||||
txtSeq = (TextView) findViewById(R.id.txt_seq);
|
txtSeq = findViewById(R.id.txt_seq);
|
||||||
|
|
||||||
animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink);
|
animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink);
|
||||||
// blink
|
|
||||||
btnBlink.setOnClickListener(
|
btnBlink.setOnClickListener(
|
||||||
new View.OnClickListener() {
|
v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
txtBlink.setVisibility(View.VISIBLE);
|
txtBlink.setVisibility(View.VISIBLE);
|
||||||
txtBlink.startAnimation(animBlink);
|
txtBlink.startAnimation(animBlink);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
animRotate = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate);
|
animRotate = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate);
|
||||||
|
|
||||||
// Rotate
|
btnRotate.setOnClickListener(v -> txtRotate.startAnimation(animRotate));
|
||||||
btnRotate.setOnClickListener(
|
|
||||||
new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
txtRotate.startAnimation(animRotate);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
animMove = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move);
|
animMove = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move);
|
||||||
// Move
|
|
||||||
btnMove.setOnClickListener(
|
btnMove.setOnClickListener(v -> txtMove.startAnimation(animMove));
|
||||||
new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
txtMove.startAnimation(animMove);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
animBounce = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.bounce);
|
animBounce = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.bounce);
|
||||||
// Slide Down
|
|
||||||
btnBounce.setOnClickListener(
|
|
||||||
new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
txtBounce.startAnimation(animBounce);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
animSequential = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.sequential);
|
|
||||||
// Sequential
|
|
||||||
btnSequential.setOnClickListener(
|
|
||||||
new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
txtSeq.startAnimation(animSequential);
|
btnBounce.setOnClickListener(v -> txtBounce.startAnimation(animBounce));
|
||||||
}
|
animSequential = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.sequential);
|
||||||
});
|
|
||||||
|
btnSequential.setOnClickListener(v -> txtSeq.startAnimation(animSequential));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ public class ButtonsActivity extends FragmentActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_buttons);
|
setContentView(R.layout.activity_buttons);
|
||||||
|
|
||||||
text = (TextView) findViewById(R.id.count);
|
text = findViewById(R.id.count);
|
||||||
|
|
||||||
button = (Button) findViewById(com.facebook.flipper.sample.R.id.btn_inc);
|
button = findViewById(com.facebook.flipper.sample.R.id.btn_inc);
|
||||||
dialogOld = (Button) findViewById(R.id.dialog_old_api);
|
dialogOld = findViewById(R.id.dialog_old_api);
|
||||||
dialogFragment = (Button) findViewById(R.id.dialog_fragment);
|
dialogFragment = findViewById(R.id.dialog_fragment);
|
||||||
button.setOnClickListener(view -> ButtonsActivity.this.text.setText(String.valueOf(++count)));
|
button.setOnClickListener(view -> ButtonsActivity.this.text.setText(String.valueOf(++count)));
|
||||||
|
|
||||||
dialogFragment.setOnClickListener(
|
dialogFragment.setOnClickListener(
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public class FlipperSampleApplication extends Application {
|
|||||||
Fresco.initialize(this);
|
Fresco.initialize(this);
|
||||||
|
|
||||||
final FlipperClient client = AndroidFlipperClient.getInstance(this);
|
final FlipperClient client = AndroidFlipperClient.getInstance(this);
|
||||||
|
assert client != null;
|
||||||
|
|
||||||
final FlipperInitializer.IntializationResult initializationResult =
|
final FlipperInitializer.IntializationResult initializationResult =
|
||||||
FlipperInitializer.initFlipperPlugins(this, client);
|
FlipperInitializer.initFlipperPlugins(this, client);
|
||||||
|
|
||||||
|
|||||||
@@ -15,39 +15,39 @@ import android.widget.TextView;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
public class FragmentTestFragment extends Fragment {
|
public class FragmentTestFragment extends Fragment {
|
||||||
View mView;
|
View view;
|
||||||
int mTicker;
|
int ticker;
|
||||||
|
|
||||||
public FragmentTestFragment() {
|
public FragmentTestFragment() {
|
||||||
mTicker = 0;
|
ticker = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTicker() {
|
private void updateTicker() {
|
||||||
try {
|
try {
|
||||||
ViewGroup viewGroup = (ViewGroup) mView;
|
ViewGroup viewGroup = (ViewGroup) view;
|
||||||
TextView textView = (TextView) viewGroup.getChildAt(1);
|
TextView textView = (TextView) viewGroup.getChildAt(1);
|
||||||
String text = String.valueOf(mTicker++);
|
String text = String.valueOf(ticker++);
|
||||||
|
|
||||||
textView.setText(text);
|
textView.setText(text);
|
||||||
} finally {
|
} finally {
|
||||||
// 100% guarantee that this always happens, even if
|
// 100% guarantee that this always happens, even if
|
||||||
// your update method throws an exception
|
// your update method throws an exception
|
||||||
mView.postDelayed(
|
view.postDelayed(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateTicker();
|
updateTicker();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
10000);
|
1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(
|
public View onCreateView(
|
||||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
mView = inflater.inflate(R.layout.fragment_test, container, false);
|
view = inflater.inflate(R.layout.fragment_test, container, false);
|
||||||
mView.postDelayed(
|
view.postDelayed(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -56,6 +56,6 @@ public class FragmentTestFragment extends Fragment {
|
|||||||
},
|
},
|
||||||
1000);
|
1000);
|
||||||
|
|
||||||
return mView;
|
return view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class ListActivity extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_list);
|
setContentView(R.layout.activity_list);
|
||||||
|
|
||||||
listView = (ListView) findViewById(R.id.list);
|
listView = findViewById(R.id.list);
|
||||||
|
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
list.add("Apple");
|
list.add("Apple");
|
||||||
@@ -33,7 +33,7 @@ public class ListActivity extends Activity {
|
|||||||
list.add("Orange");
|
list.add("Orange");
|
||||||
list.add("Lychee");
|
list.add("Lychee");
|
||||||
list.add("Guava");
|
list.add("Guava");
|
||||||
list.add("Peech");
|
list.add("Peach");
|
||||||
list.add("Melon");
|
list.add("Melon");
|
||||||
list.add("Watermelon");
|
list.add("Watermelon");
|
||||||
list.add("Papaya");
|
list.add("Papaya");
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
final FlipperClient client = AndroidFlipperClient.getInstanceIfInitialized();
|
final FlipperClient client = AndroidFlipperClient.getInstanceIfInitialized();
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
final ExampleFlipperPlugin samplePlugin = client.getPluginByClass(ExampleFlipperPlugin.class);
|
final ExampleFlipperPlugin samplePlugin = client.getPluginByClass(ExampleFlipperPlugin.class);
|
||||||
|
if (samplePlugin != null) {
|
||||||
samplePlugin.setActivity(this);
|
samplePlugin.setActivity(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ package com.facebook.flipper.sample;
|
|||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
|
||||||
public class TestDialogFragment extends DialogFragment {
|
public class TestDialogFragment extends DialogFragment {
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
// Use the Builder class for convenient dialog construction
|
// Use the Builder class for convenient dialog construction
|
||||||
|
|||||||
Reference in New Issue
Block a user