Skip to content

Commit

Permalink
Testing with a library
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Diaz committed Sep 29, 2016
1 parent 53c607b commit 9dc90d2
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,6 @@ dependencies {
provided libraries.autoValueAnnotations

provided libraries.xposed

compile 'com.splitwise:tokenautocomplete:2.0.8@aar'
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.ArrayAdapter;

import com.icecream.snorlax.R;

Expand All @@ -42,6 +43,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mUnbinder = ButterKnife.bind(this);

setupToolbar();
setupOptions();
}

private void setupToolbar() {
Expand All @@ -51,4 +53,15 @@ private void setupToolbar() {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}

private void setupOptions() {
RenameOptions[] options = new RenameOptions[]{
RenameOptions.create("IV"),
RenameOptions.create("ATT"),
RenameOptions.create("DEF"),
RenameOptions.create("STA")
};

ArrayAdapter<RenameOptions> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, options);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2016. Pedro Diaz <igoticecream@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.icecream.snorlax.app.rename;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;

import com.tokenautocomplete.TokenCompleteTextView;

@SuppressWarnings({"unused", "WeakerAccess", "FieldCanBeLocal"})
public class RenameCompletionView extends TokenCompleteTextView<RenameOptions> {

private final LayoutInflater mLayoutInflater;

public RenameCompletionView(Context context, AttributeSet attrs) {
super(context, attrs);
mLayoutInflater = LayoutInflater.from(context);
}

@Override
protected View getViewForObject(RenameOptions person) {
/*
TextView view = (TextView) mLayoutInflater.inflate(R.layout.contact_token, (ViewGroup) getParent(), false);
view.setText(person.getOption());
return view;
*/
return null;
}

@Override
protected RenameOptions defaultObject(String completionText) {
//Stupid simple example of guessing if we have an email or not
/*
int index = completionText.indexOf('@');
if (index == -1) {
return new Person(completionText, completionText.replace(" ", "") + "@example.com");
}
else {
return new Person(completionText.substring(0, index), completionText);
}
*/
return RenameOptions.create("Dummy");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2016. Pedro Diaz <igoticecream@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.icecream.snorlax.app.rename;

import java.io.Serializable;

import com.google.auto.value.AutoValue;

@AutoValue
@SuppressWarnings({"unused", "WeakerAccess", "FieldCanBeLocal"})
abstract class RenameOptions implements Serializable {

static RenameOptions create(String option) {
return new AutoValue_RenameOptions(option);
}

abstract String getOption();
}

0 comments on commit 9dc90d2

Please sign in to comment.