cleaned all warnings from Android example
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
android:theme="@android:style/Theme.Holo.Light.DarkActionBar">
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.MainActivity"
|
||||
android:name="net.irext.ircontrol.ui.activity.MainActivity"
|
||||
android:label="@string/title_activity_main"
|
||||
android:theme="@style/AppTheme">
|
||||
<intent-filter>
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.irext.webapi.WebAPICallbacks.SignInCallback;
|
||||
* Revision log:
|
||||
* 2017-03-28: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class IRApplication extends com.activeandroid.app.Application {
|
||||
|
||||
private static final String TAG = IRApplication.class.getSimpleName();
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
@Table(name = "RemoteControl")
|
||||
@SuppressWarnings("unused")
|
||||
public class RemoteControl extends Model {
|
||||
|
||||
@Column(name = "CategoryID")
|
||||
|
||||
@@ -18,9 +18,9 @@ import net.irext.ircontrol.ui.fragment.ControlFragment;
|
||||
* Revision log:
|
||||
* 2017-04-22: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ControlActivity extends AppCompatActivity {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = ControlActivity.class.getSimpleName();
|
||||
|
||||
public static final String KEY_REMOTE_ID = "KEY_REMOTE_ID";
|
||||
@@ -44,10 +44,9 @@ public class ControlActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
return true;
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class CreateActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = CreateActivity.class.getSimpleName();
|
||||
@@ -67,10 +68,9 @@ public class CreateActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
return true;
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public class CreateActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
int cmd = msg.getData().getInt(MessageUtil.KEY_CMD);
|
||||
Log.d(TAG, "handle message " + Integer.toString(cmd));
|
||||
Log.d(TAG, "handle message " + cmd);
|
||||
|
||||
CreateActivity createActivity = mCreateActivity.get();
|
||||
switch (cmd) {
|
||||
|
||||
@@ -7,11 +7,10 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
@@ -33,19 +32,32 @@ import java.lang.ref.WeakReference;
|
||||
* Revision log:
|
||||
* 2017-04-04: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = MainActivity.class.getSimpleName();
|
||||
|
||||
public static final int CMD_GOTO_CONTROL = 0;
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
private MainFragment mRemoteListFragment;
|
||||
|
||||
private RemoteControl mCurrentRemoteControl;
|
||||
|
||||
public MsgHandler mMsgHandler;
|
||||
|
||||
public RemoteControl getCurrentRemoteControl() {
|
||||
return mCurrentRemoteControl;
|
||||
}
|
||||
|
||||
public MainActivity() {
|
||||
}
|
||||
|
||||
public void setCurrentRemoteControl(RemoteControl mCurrentRemoteControl) {
|
||||
this.mCurrentRemoteControl = mCurrentRemoteControl;
|
||||
}
|
||||
|
||||
public MainActivity(RemoteControl mCurrentRemoteControl) {
|
||||
this.mCurrentRemoteControl = mCurrentRemoteControl;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -56,33 +68,25 @@ public class MainActivity extends AppCompatActivity {
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
mFragmentManager = this.getSupportFragmentManager();
|
||||
mRemoteListFragment = (MainFragment) mFragmentManager.findFragmentById(R.id.fragment_remote);
|
||||
FragmentManager mFragmentManager = this.getSupportFragmentManager();
|
||||
MainFragment mRemoteListFragment = (MainFragment) mFragmentManager.findFragmentById(R.id.fragment_remote);
|
||||
|
||||
if (null == mRemoteListFragment) {
|
||||
Log.e(TAG, "MainFragment is null");
|
||||
}
|
||||
assert mRemoteListFragment != null;
|
||||
mRemoteListFragment.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
Log.d(TAG, "BUTTON PRESSED");
|
||||
return true;
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
Log.d(TAG, "BUTTON PRESSED");
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public RemoteControl getmCurrentRemoteControl() {
|
||||
return mCurrentRemoteControl;
|
||||
}
|
||||
|
||||
public void setmCurrentRemoteControl(RemoteControl mCurrentRemoteControl) {
|
||||
this.mCurrentRemoteControl = mCurrentRemoteControl;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
@@ -98,41 +102,36 @@ public class MainActivity extends AppCompatActivity {
|
||||
isWriteStoragePermissionGranted();
|
||||
}
|
||||
|
||||
public boolean isReadStoragePermissionGranted() {
|
||||
public void isReadStoragePermissionGranted() {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
Log.v(TAG,"read permission is granted");
|
||||
return true;
|
||||
} else {
|
||||
|
||||
Log.v(TAG,"read permission is revoked");
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 3);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else { //permission is automatically granted on sdk<23 upon installation
|
||||
Log.v(TAG,"read permission is granted");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWriteStoragePermissionGranted() {
|
||||
public void isWriteStoragePermissionGranted() {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
Log.v(TAG,"write permission is granted");
|
||||
return true;
|
||||
} else {
|
||||
|
||||
Log.v(TAG,"write permission is revoked");
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else { //permission is automatically granted on sdk<23 upon installation
|
||||
else {
|
||||
// permission is automatically granted on sdk<23 upon installation
|
||||
Log.v(TAG,"write permission is granted");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,25 +159,18 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
int cmd = msg.getData().getInt(MessageUtil.KEY_CMD);
|
||||
Log.d(TAG, "handle message " + Integer.toString(cmd));
|
||||
Log.d(TAG, "handle message " + cmd);
|
||||
|
||||
MainActivity mainActivity = mMainActivity.get();
|
||||
switch (cmd) {
|
||||
case CMD_GOTO_CONTROL:
|
||||
mainActivity.gotoControl();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
if (cmd == CMD_GOTO_CONTROL) {
|
||||
mainActivity.gotoControl();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
switch (requestCode) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-07: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class BrandAdapter extends BaseAdapter {
|
||||
|
||||
private List<Brand> mBrands;
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-07: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class CategoryAdapter extends BaseAdapter {
|
||||
|
||||
private List<Category> mCategories;
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-07: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class CityAdapter extends BaseAdapter {
|
||||
|
||||
private List<City> mCities;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.irext.ircontrol.ui.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -23,6 +24,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-07: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class IndexAdapter extends BaseAdapter {
|
||||
|
||||
private List<RemoteIndex> mIndexes;
|
||||
@@ -52,6 +54,7 @@ public class IndexAdapter extends BaseAdapter {
|
||||
return position;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
ViewHolder holder;
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-10: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class OperatorAdapter extends BaseAdapter {
|
||||
|
||||
private List<StbOperator> mOperators;
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-15: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class RemoteControlAdapter extends BaseAdapter {
|
||||
|
||||
private List<RemoteControl> mRemoteControls;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.irext.ircontrol.ui.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -20,6 +21,7 @@ import net.irext.ircontrol.utils.MessageUtil;
|
||||
* Revision log:
|
||||
* 2017-04-10: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class BaseCreateFragment extends Fragment {
|
||||
|
||||
protected static final String TAG = BaseCreateFragment.class.getSimpleName();
|
||||
@@ -28,20 +30,20 @@ public abstract class BaseCreateFragment extends Fragment {
|
||||
CreateActivity mParent;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mParent = (CreateActivity) getActivity();
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean onBackPressed() {
|
||||
public void onBackPressed() {
|
||||
if (-1 != mFrom) {
|
||||
MessageUtil.postMessage(mParent.mMsgHandler, mFrom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void getFrom() {
|
||||
assert getArguments() != null;
|
||||
int from = getArguments().getInt(CreateActivity.KEY_FROM);
|
||||
if (-1 == from) {
|
||||
Log.d(TAG, "FROM IS NULL");
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.irext.ircontrol.ui.fragment;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -21,6 +22,7 @@ import net.irext.webapi.model.Brand;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Filename: BrandFragment.java
|
||||
@@ -32,6 +34,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-07: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class BrandFragment extends BaseCreateFragment {
|
||||
|
||||
private static final String TAG = BrandFragment.class.getSimpleName();
|
||||
@@ -89,12 +92,12 @@ public class BrandFragment extends BaseCreateFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
getFrom();
|
||||
View view = inflater.inflate(R.layout.fragment_brand, container, false);
|
||||
mApp = (IRApplication) getActivity().getApplication();
|
||||
mApp = (IRApplication) Objects.requireNonNull(getActivity()).getApplication();
|
||||
|
||||
mMsgHandler = new MsgHandler(this);
|
||||
|
||||
@@ -124,9 +127,8 @@ public class BrandFragment extends BaseCreateFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class MsgHandler extends Handler {
|
||||
@@ -140,17 +142,11 @@ public class BrandFragment extends BaseCreateFragment {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
int cmd = msg.getData().getInt(MessageUtil.KEY_CMD);
|
||||
Log.d(TAG, "handle message " + Integer.toString(cmd));
|
||||
Log.d(TAG, "handle message " + cmd);
|
||||
|
||||
BrandFragment brandFragment = mBrandFragment.get();
|
||||
switch (cmd) {
|
||||
|
||||
case CMD_REFRESH_BRAND_LIST:
|
||||
brandFragment.refreshBrands();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
if (cmd == CMD_REFRESH_BRAND_LIST) {
|
||||
brandFragment.refreshBrands();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.irext.ircontrol.ui.fragment;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -22,6 +23,7 @@ import net.irext.webapi.WebAPICallbacks.ListCategoriesCallback;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Filename: CategoryFragment.java
|
||||
@@ -33,6 +35,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-07: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class CategoryFragment extends BaseCreateFragment {
|
||||
|
||||
private static final String TAG = CategoryFragment.class.getSimpleName();
|
||||
@@ -87,12 +90,12 @@ public class CategoryFragment extends BaseCreateFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
mFrom = -1;
|
||||
View view = inflater.inflate(R.layout.fragment_category, container, false);
|
||||
mApp = (IRApplication) getActivity().getApplication();
|
||||
mApp = (IRApplication) Objects.requireNonNull(getActivity()).getApplication();
|
||||
|
||||
mMsgHandler = new MsgHandler(this);
|
||||
|
||||
@@ -127,8 +130,8 @@ public class CategoryFragment extends BaseCreateFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
return false;
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private static class MsgHandler extends Handler {
|
||||
@@ -142,17 +145,11 @@ public class CategoryFragment extends BaseCreateFragment {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
int cmd = msg.getData().getInt(MessageUtil.KEY_CMD);
|
||||
Log.d(TAG, "handle message " + Integer.toString(cmd));
|
||||
Log.d(TAG, "handle message " + cmd);
|
||||
|
||||
CategoryFragment categoryFragment = mCategoryFragment.get();
|
||||
switch (cmd) {
|
||||
|
||||
case CMD_REFRESH_CATEGORY_LIST:
|
||||
categoryFragment.refreshCategories();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
if (cmd == CMD_REFRESH_CATEGORY_LIST) {
|
||||
categoryFragment.refreshCategories();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.irext.ircontrol.ui.fragment;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -27,6 +28,7 @@ import net.irext.webapi.model.StbOperator;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Filename: CityFragment.java
|
||||
@@ -38,6 +40,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-07: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class CityFragment extends BaseCreateFragment {
|
||||
|
||||
private static final String TAG = CityFragment.class.getSimpleName();
|
||||
@@ -201,12 +204,12 @@ public class CityFragment extends BaseCreateFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
getFrom();
|
||||
View view = inflater.inflate(R.layout.fragment_city, container, false);
|
||||
mApp = (IRApplication) getActivity().getApplication();
|
||||
mApp = (IRApplication) Objects.requireNonNull(getActivity()).getApplication();
|
||||
|
||||
mMsgHandler = new MsgHandler(this);
|
||||
|
||||
@@ -249,16 +252,15 @@ public class CityFragment extends BaseCreateFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
public void onBackPressed() {
|
||||
if (LEVEL_PROVINCE == mListLevel) {
|
||||
return super.onBackPressed();
|
||||
super.onBackPressed();
|
||||
} else if (LEVEL_CITY == mListLevel) {
|
||||
listProvinces();
|
||||
} else if (LEVEL_OPERATOR == mListLevel) {
|
||||
String prefix = mCurrentProvince.getCode().substring(0, 2);
|
||||
listCities(prefix);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class MsgHandler extends Handler {
|
||||
@@ -272,7 +274,7 @@ public class CityFragment extends BaseCreateFragment {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
int cmd = msg.getData().getInt(MessageUtil.KEY_CMD);
|
||||
Log.d(TAG, "handle message " + Integer.toString(cmd));
|
||||
Log.d(TAG, "handle message " + cmd);
|
||||
|
||||
CityFragment cityFragment = mCityFragment.get();
|
||||
switch (cmd) {
|
||||
|
||||
@@ -23,8 +23,6 @@ import net.irext.ircontrol.ui.activity.ControlActivity;
|
||||
import net.irext.ircontrol.utils.FileUtils;
|
||||
import net.irext.ircontrol.utils.MessageUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
@@ -37,6 +35,7 @@ import java.lang.ref.WeakReference;
|
||||
* Revision log:
|
||||
* 2017-04-22: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class ControlFragment extends Fragment implements View.OnClickListener {
|
||||
|
||||
private static final String TAG = ControlFragment.class.getSimpleName();
|
||||
@@ -110,6 +109,7 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
assert getArguments() != null;
|
||||
mRemoteID = getArguments().getLong(ControlActivity.KEY_REMOTE_ID, -1L);
|
||||
if (-1 == mRemoteID) {
|
||||
Log.d(TAG, "remote ID IS NULL");
|
||||
@@ -278,14 +278,8 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
|
||||
int cmd = msg.getData().getInt(MessageUtil.KEY_CMD);
|
||||
|
||||
ControlFragment controlFragment = mMainFragment.get();
|
||||
switch (cmd) {
|
||||
|
||||
case CMD_GET_REMOTE_CONTROL:
|
||||
controlFragment.showRemote();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
if (cmd == CMD_GET_REMOTE_CONTROL) {
|
||||
controlFragment.showRemote();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.irext.ircontrol.ui.fragment;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -30,6 +31,7 @@ import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Filename: IndexFragment.java
|
||||
@@ -41,6 +43,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-12: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class IndexFragment extends BaseCreateFragment {
|
||||
|
||||
private static final String TAG = IndexFragment.class.getSimpleName();
|
||||
@@ -201,14 +204,14 @@ public class IndexFragment extends BaseCreateFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
getFrom();
|
||||
View view = inflater.inflate(R.layout.fragment_index, container, false);
|
||||
|
||||
mMsgHandler = new MsgHandler(this);
|
||||
mApp = (IRApplication) this.getActivity().getApplication();
|
||||
mApp = (IRApplication) Objects.requireNonNull(this.getActivity()).getApplication();
|
||||
|
||||
Category category = mParent.getCurrentCategory();
|
||||
Brand brand = mParent.getCurrentBrand();
|
||||
@@ -252,8 +255,8 @@ public class IndexFragment extends BaseCreateFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
return super.onBackPressed();
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private static class MsgHandler extends Handler {
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.List;
|
||||
* Revision log:
|
||||
* 2017-04-04: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class MainFragment extends Fragment {
|
||||
|
||||
private static final String TAG = MainFragment.class.getSimpleName();
|
||||
@@ -77,7 +78,7 @@ public class MainFragment extends Fragment {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
RemoteControl remoteControl = (RemoteControl)mRemoteControlAdapter.getItem(position);
|
||||
mParent.setmCurrentRemoteControl(remoteControl);
|
||||
mParent.setCurrentRemoteControl(remoteControl);
|
||||
MessageUtil.postMessage(mParent.mMsgHandler, MainActivity.CMD_GOTO_CONTROL);
|
||||
}
|
||||
});
|
||||
@@ -126,17 +127,11 @@ public class MainFragment extends Fragment {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
int cmd = msg.getData().getInt(MessageUtil.KEY_CMD);
|
||||
Log.d(TAG, "handle message " + Integer.toString(cmd));
|
||||
Log.d(TAG, "handle message " + cmd);
|
||||
|
||||
MainFragment mainFragment = mMainFragment.get();
|
||||
switch (cmd) {
|
||||
|
||||
case CMD_REFRESH_REMOTE_LIST:
|
||||
mainFragment.refreshRemoteList();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
if (cmd == CMD_REFRESH_REMOTE_LIST) {
|
||||
mainFragment.refreshRemoteList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.irext.ircontrol.ui.widget;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.*;
|
||||
@@ -31,6 +32,7 @@ import java.util.Date;
|
||||
* @author Erik Wallentinsen <dev+ptr@erikw.eu>
|
||||
* @version 1.3.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class PullToRefreshListView extends ListView{
|
||||
|
||||
private static final float PULL_RESISTANCE = 1.7f;
|
||||
@@ -39,7 +41,7 @@ public class PullToRefreshListView extends ListView{
|
||||
private static final float BOUNCE_OVERSHOOT_TENSION = 1.4f;
|
||||
private static final int ROTATE_ARROW_ANIMATION_DURATION = 250;
|
||||
|
||||
private static enum State{
|
||||
private enum State{
|
||||
PULL_TO_REFRESH,
|
||||
RELEASE_TO_REFRESH,
|
||||
REFRESHING
|
||||
@@ -55,7 +57,7 @@ public class PullToRefreshListView extends ListView{
|
||||
/**
|
||||
* Method to be called when a refresh is requested
|
||||
*/
|
||||
public void onRefresh();
|
||||
void onRefresh();
|
||||
}
|
||||
|
||||
private static int measuredHeaderHeight;
|
||||
@@ -68,6 +70,7 @@ public class PullToRefreshListView extends ListView{
|
||||
private String releaseToRefreshText;
|
||||
private String refreshingText;
|
||||
private String lastUpdatedText;
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private SimpleDateFormat lastUpdatedDateFormat = new SimpleDateFormat("dd/MM HH:mm");
|
||||
|
||||
private float previousY;
|
||||
@@ -88,7 +91,6 @@ public class PullToRefreshListView extends ListView{
|
||||
private OnRefreshListener onRefreshListener;
|
||||
|
||||
private float mScrollStartY;
|
||||
private final int IDLE_DISTANCE = 5;
|
||||
|
||||
public PullToRefreshListView(Context context){
|
||||
super(context);
|
||||
@@ -136,7 +138,7 @@ public class PullToRefreshListView extends ListView{
|
||||
* Default is false. When lockScrollWhileRefreshing is set to true, the list
|
||||
* cannot scroll when in 'refreshing' mode. It's 'locked' on refreshing.
|
||||
*
|
||||
* @param lockScrollWhileRefreshing
|
||||
* @param lockScrollWhileRefreshing : lock scroll while refreshing
|
||||
*/
|
||||
public void setLockScrollWhileRefreshing(boolean lockScrollWhileRefreshing){
|
||||
this.lockScrollWhileRefreshing = lockScrollWhileRefreshing;
|
||||
@@ -146,7 +148,7 @@ public class PullToRefreshListView extends ListView{
|
||||
* Default is false. Show the last-updated date/time in the 'Pull ro Refresh'
|
||||
* header. See 'setLastUpdatedDateFormat' to set the date/time formatting.
|
||||
*
|
||||
* @param showLastUpdatedText
|
||||
* @param showLastUpdatedText : show last update text
|
||||
*/
|
||||
public void setShowLastUpdatedText(boolean showLastUpdatedText){
|
||||
this.showLastUpdatedText = showLastUpdatedText;
|
||||
@@ -158,7 +160,7 @@ public class PullToRefreshListView extends ListView{
|
||||
* date/time is shown. Meaningless if 'showLastUpdatedText == false (default)'.
|
||||
* See 'setShowLastUpdatedText'.
|
||||
*
|
||||
* @param lastUpdatedDateFormat
|
||||
* @param lastUpdatedDateFormat : last updated date format
|
||||
*/
|
||||
public void setLastUpdatedDateFormat(SimpleDateFormat lastUpdatedDateFormat){
|
||||
this.lastUpdatedDateFormat = lastUpdatedDateFormat;
|
||||
@@ -269,6 +271,7 @@ public class PullToRefreshListView extends ListView{
|
||||
header.setLayoutParams(mlp);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event){
|
||||
if(lockScrollWhileRefreshing
|
||||
@@ -276,6 +279,7 @@ public class PullToRefreshListView extends ListView{
|
||||
return true;
|
||||
}
|
||||
|
||||
int IDLE_DISTANCE = 5;
|
||||
switch(event.getAction()){
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
if(getFirstVisiblePosition() == 0){
|
||||
@@ -340,7 +344,7 @@ public class PullToRefreshListView extends ListView{
|
||||
private void bounceBackHeader(){
|
||||
int yTranslate = state == State.REFRESHING ?
|
||||
header.getHeight() - headerContainer.getHeight() :
|
||||
-headerContainer.getHeight() - headerContainer.getTop() + getPaddingTop();;
|
||||
-headerContainer.getHeight() - headerContainer.getTop() + getPaddingTop();
|
||||
|
||||
TranslateAnimation bounceAnimation = new TranslateAnimation(
|
||||
TranslateAnimation.ABSOLUTE, 0,
|
||||
@@ -491,13 +495,13 @@ public class PullToRefreshListView extends ListView{
|
||||
if(initialHeaderHeight > 0){
|
||||
measuredHeaderHeight = initialHeaderHeight;
|
||||
|
||||
if(measuredHeaderHeight > 0 && state != State.REFRESHING){
|
||||
if(state != State.REFRESHING){
|
||||
setHeaderPadding(-measuredHeaderHeight);
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ package net.irext.ircontrol.utils;
|
||||
* Revision log:
|
||||
* 2017-04-03: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class Constants {
|
||||
|
||||
public static final String KEY_ADMIN_ID = "id";
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.io.*;
|
||||
* Revision log:
|
||||
* 2017-04-14: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class FileUtils {
|
||||
|
||||
private static final String TAG = FileUtils.class.getSimpleName();
|
||||
@@ -121,7 +122,7 @@ public class FileUtils {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
int count;
|
||||
byte buffer[] = new byte[512];
|
||||
byte[] buffer = new byte[512];
|
||||
while ((count = fis.read(buffer)) > 0) {
|
||||
baos.write(buffer, 0, count);
|
||||
}
|
||||
@@ -137,7 +138,7 @@ public class FileUtils {
|
||||
}
|
||||
|
||||
private static void deleteAllFiles(File root) {
|
||||
File files[] = root.listFiles();
|
||||
File[] files = root.listFiles();
|
||||
if (files != null) {
|
||||
for (File f : files) {
|
||||
if (f.isDirectory()) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.os.Message;
|
||||
* Revision log:
|
||||
* 2017-04-08: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class MessageUtil {
|
||||
|
||||
public static final String KEY_CMD = "CMD";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.irext.ircontrol.utils;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
@@ -16,6 +17,7 @@ import java.util.HashMap;
|
||||
* Revision log:
|
||||
* 2017-04-05: created by strawmanbobi
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class SharedPreferenceUtil {
|
||||
|
||||
private static final String TAG = SharedPreferenceUtil.class.getSimpleName();
|
||||
@@ -23,13 +25,13 @@ public class SharedPreferenceUtil {
|
||||
private static final String _NAME = "irext";
|
||||
private static SharedPreferences mSharedPreferences;
|
||||
private static SharedPreferences.Editor mEditor;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static SharedPreferenceUtil mSharedPreferenceUtils = null;
|
||||
private Context mContext;
|
||||
|
||||
public SharedPreferenceUtil(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@SuppressLint("CommitPrefEdits")
|
||||
public static SharedPreferenceUtil getInstance(Context context) {
|
||||
if (null == mSharedPreferenceUtils) {
|
||||
mSharedPreferenceUtils = new SharedPreferenceUtil(context);
|
||||
|
||||
Reference in New Issue
Block a user