Fix some SonarLint warnings in AddFeedActivity
This commit is contained in:
parent
272e867c8d
commit
1a38155c01
@ -11,7 +11,6 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentPagerAdapter;
|
import androidx.fragment.app.FragmentPagerAdapter;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import com.readrops.app.R;
|
import com.readrops.app.R;
|
||||||
@ -30,10 +29,9 @@ import io.reactivex.schedulers.Schedulers;
|
|||||||
|
|
||||||
public class ManageFeedsFoldersActivity extends AppCompatActivity {
|
public class ManageFeedsFoldersActivity extends AppCompatActivity {
|
||||||
|
|
||||||
public static final String ACCOUNT = "ACCOUNT";
|
public static final String ACCOUNT_KEY = "ACCOUNT_KEY";
|
||||||
|
|
||||||
private ActivityManageFeedsFoldersBinding binding;
|
private ActivityManageFeedsFoldersBinding binding;
|
||||||
private FeedsFoldersPageAdapter pageAdapter;
|
|
||||||
private ManageFeedsFoldersViewModel viewModel;
|
private ManageFeedsFoldersViewModel viewModel;
|
||||||
|
|
||||||
private Account account;
|
private Account account;
|
||||||
@ -46,32 +44,15 @@ public class ManageFeedsFoldersActivity extends AppCompatActivity {
|
|||||||
setSupportActionBar(binding.manageFeedsFoldersToolbar);
|
setSupportActionBar(binding.manageFeedsFoldersToolbar);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
account = getIntent().getParcelableExtra(ACCOUNT);
|
account = getIntent().getParcelableExtra(ACCOUNT_KEY);
|
||||||
|
|
||||||
pageAdapter = new FeedsFoldersPageAdapter(getSupportFragmentManager());
|
FeedsFoldersPageAdapter pageAdapter = new FeedsFoldersPageAdapter(getSupportFragmentManager());
|
||||||
|
|
||||||
binding.manageFeedsFoldersViewpager.setAdapter(pageAdapter);
|
binding.manageFeedsFoldersViewpager.setAdapter(pageAdapter);
|
||||||
binding.manageFeedsFoldersTablayout.setupWithViewPager(binding.manageFeedsFoldersViewpager);
|
binding.manageFeedsFoldersTablayout.setupWithViewPager(binding.manageFeedsFoldersViewpager);
|
||||||
|
|
||||||
viewModel = ViewModelProviders.of(this).get(ManageFeedsFoldersViewModel.class);
|
viewModel = ViewModelProviders.of(this).get(ManageFeedsFoldersViewModel.class);
|
||||||
viewModel.setAccount(account);
|
viewModel.setAccount(account);
|
||||||
|
|
||||||
binding.manageFeedsFoldersViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int position) {
|
|
||||||
binding.manageFeedsFoldersTablayout.getTabAt(position).select();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -92,8 +73,9 @@ public class ManageFeedsFoldersActivity extends AppCompatActivity {
|
|||||||
case R.id.add_folder:
|
case R.id.add_folder:
|
||||||
addFolder();
|
addFolder();
|
||||||
return true;
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -132,7 +114,7 @@ public class ManageFeedsFoldersActivity extends AppCompatActivity {
|
|||||||
public class FeedsFoldersPageAdapter extends FragmentPagerAdapter {
|
public class FeedsFoldersPageAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
private FeedsFoldersPageAdapter(FragmentManager fragmentManager) {
|
private FeedsFoldersPageAdapter(FragmentManager fragmentManager) {
|
||||||
super(fragmentManager);
|
super(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,7 @@ import java.util.TreeMap;
|
|||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
import static com.readrops.app.activities.ManageFeedsFoldersActivity.ACCOUNT;
|
import static com.readrops.app.activities.ManageFeedsFoldersActivity.ACCOUNT_KEY;
|
||||||
|
|
||||||
public class EditFeedDialogFragment extends DialogFragment implements AdapterView.OnItemSelectedListener {
|
public class EditFeedDialogFragment extends DialogFragment implements AdapterView.OnItemSelectedListener {
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class EditFeedDialogFragment extends DialogFragment implements AdapterVie
|
|||||||
public static EditFeedDialogFragment newInstance(FeedWithFolder feedWithFolder, Account account) {
|
public static EditFeedDialogFragment newInstance(FeedWithFolder feedWithFolder, Account account) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable("feedWithFolder", feedWithFolder);
|
args.putParcelable("feedWithFolder", feedWithFolder);
|
||||||
args.putParcelable(ACCOUNT, account);
|
args.putParcelable(ACCOUNT_KEY, account);
|
||||||
|
|
||||||
EditFeedDialogFragment fragment = new EditFeedDialogFragment();
|
EditFeedDialogFragment fragment = new EditFeedDialogFragment();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
@ -63,7 +63,7 @@ public class EditFeedDialogFragment extends DialogFragment implements AdapterVie
|
|||||||
viewModel = ViewModelProviders.of(getActivity()).get(ManageFeedsFoldersViewModel.class);
|
viewModel = ViewModelProviders.of(getActivity()).get(ManageFeedsFoldersViewModel.class);
|
||||||
|
|
||||||
feedWithFolder = getArguments().getParcelable("feedWithFolder");
|
feedWithFolder = getArguments().getParcelable("feedWithFolder");
|
||||||
account = getArguments().getParcelable(ManageFeedsFoldersActivity.ACCOUNT);
|
account = getArguments().getParcelable(ManageFeedsFoldersActivity.ACCOUNT_KEY);
|
||||||
|
|
||||||
viewModel.setAccount(account);
|
viewModel.setAccount(account);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import android.view.ViewGroup
|
|||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
import com.readrops.app.R
|
import com.readrops.app.R
|
||||||
import com.readrops.app.activities.ManageFeedsFoldersActivity.ACCOUNT
|
import com.readrops.app.activities.ManageFeedsFoldersActivity.ACCOUNT_KEY
|
||||||
import com.readrops.app.database.entities.account.Account
|
import com.readrops.app.database.entities.account.Account
|
||||||
import com.readrops.app.database.pojo.FeedWithFolder
|
import com.readrops.app.database.pojo.FeedWithFolder
|
||||||
import com.readrops.app.databinding.FeedOptionsLayoutBinding
|
import com.readrops.app.databinding.FeedOptionsLayoutBinding
|
||||||
@ -26,7 +26,7 @@ class FeedOptionsDialogFragment : BottomSheetDialogFragment() {
|
|||||||
fun newInstance(feedWithFolder: FeedWithFolder, account: Account): FeedOptionsDialogFragment {
|
fun newInstance(feedWithFolder: FeedWithFolder, account: Account): FeedOptionsDialogFragment {
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
bundle.putParcelable(FEED_KEY, feedWithFolder)
|
bundle.putParcelable(FEED_KEY, feedWithFolder)
|
||||||
bundle.putParcelable(ACCOUNT, account)
|
bundle.putParcelable(ACCOUNT_KEY, account)
|
||||||
|
|
||||||
val feedsOptionsDialogFragment = FeedOptionsDialogFragment()
|
val feedsOptionsDialogFragment = FeedOptionsDialogFragment()
|
||||||
feedsOptionsDialogFragment.arguments = bundle
|
feedsOptionsDialogFragment.arguments = bundle
|
||||||
@ -39,7 +39,7 @@ class FeedOptionsDialogFragment : BottomSheetDialogFragment() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
feedWithFolder = arguments?.getParcelable(FEED_KEY)!!
|
feedWithFolder = arguments?.getParcelable(FEED_KEY)!!
|
||||||
account = arguments?.getParcelable(ACCOUNT)!!
|
account = arguments?.getParcelable(ACCOUNT_KEY)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
@ -29,7 +29,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
|||||||
import io.reactivex.observers.DisposableCompletableObserver;
|
import io.reactivex.observers.DisposableCompletableObserver;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
import static com.readrops.app.activities.ManageFeedsFoldersActivity.ACCOUNT;
|
import static com.readrops.app.activities.ManageFeedsFoldersActivity.ACCOUNT_KEY;
|
||||||
|
|
||||||
|
|
||||||
public class FeedsFragment extends Fragment {
|
public class FeedsFragment extends Fragment {
|
||||||
@ -58,7 +58,7 @@ public class FeedsFragment extends Fragment {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
account = getArguments().getParcelable(ACCOUNT);
|
account = getArguments().getParcelable(ACCOUNT_KEY);
|
||||||
|
|
||||||
if (account.getLogin() == null)
|
if (account.getLogin() == null)
|
||||||
account.setLogin(SharedPreferencesManager.readString(getContext(), account.getLoginKey()));
|
account.setLogin(SharedPreferencesManager.readString(getContext(), account.getLoginKey()));
|
||||||
|
@ -46,7 +46,7 @@ public class FoldersFragment extends Fragment {
|
|||||||
FoldersFragment fragment = new FoldersFragment();
|
FoldersFragment fragment = new FoldersFragment();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable(ManageFeedsFoldersActivity.ACCOUNT, account);
|
args.putParcelable(ManageFeedsFoldersActivity.ACCOUNT_KEY, account);
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
|
|
||||||
return fragment;
|
return fragment;
|
||||||
@ -56,7 +56,7 @@ public class FoldersFragment extends Fragment {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
account = getArguments().getParcelable(ManageFeedsFoldersActivity.ACCOUNT);
|
account = getArguments().getParcelable(ManageFeedsFoldersActivity.ACCOUNT_KEY);
|
||||||
|
|
||||||
if (account.getLogin() == null)
|
if (account.getLogin() == null)
|
||||||
account.setLogin(SharedPreferencesManager.readString(getContext(), account.getLoginKey()));
|
account.setLogin(SharedPreferencesManager.readString(getContext(), account.getLoginKey()));
|
||||||
|
@ -27,7 +27,7 @@ import io.reactivex.schedulers.Schedulers;
|
|||||||
*/
|
*/
|
||||||
public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
public static final String ACCOUNT = "ACCOUNT";
|
public static final String ACCOUNT = "ACCOUNT_KEY";
|
||||||
|
|
||||||
private Account account;
|
private Account account;
|
||||||
private AccountViewModel viewModel;
|
private AccountViewModel viewModel;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user