Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e2fb3b
commit 088add4
Showing
23 changed files
with
153 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...ystarter-compiler/src/main/java/activitystarter/compiler/generation/ParcelerGeneration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package activitystarter.compiler.generation | ||
|
||
class ParcelerGeneration() { | ||
|
||
fun wrap(f: () -> String): String { | ||
return "org.parceler.Parcels.wrap(${f()})" | ||
} | ||
|
||
fun unwrap(f: () -> String): String { | ||
return "org.parceler.Parcels.unwrap(${f()})" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
activitystarter-parceler-arg-converter/src/main/AndroidManifest.xml
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
...main/java/com/marcinmoskala/activitystarterparcelerargconverter/ParcelerArgConverter.java
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
activitystarter-parceler-arg-converter/src/main/res/values/strings.xml
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
.../src/test/java/com/marcinmoskala/activitystarterparcelerargconverter/ExampleUnitTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
********com.example.activitystarter.MainActivity******** | ||
package com.example.activitystarter; | ||
import android.app.Activity; | ||
import activitystarter.Arg; | ||
import org.parceler.Parcel; | ||
|
||
public class MainActivity extends Activity { | ||
|
||
@Arg(parceler = true) StudentParcel studentParceler; | ||
|
||
@Parcel | ||
public static class StudentParcel { | ||
|
||
private int id; | ||
private String name; | ||
private char grade; | ||
|
||
public StudentParcel() { | ||
} | ||
|
||
public StudentParcel(int id, String name, char grade) { | ||
this.id = id; | ||
this.name = name; | ||
this.grade = grade; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public char getGrade() { | ||
return grade; | ||
} | ||
|
||
public void setGrade(char grade) { | ||
this.grade = grade; | ||
} | ||
} | ||
} | ||
********com.example.activitystarter.MainActivityStarter******** | ||
package com.example.activitystarter; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import java.lang.String; | ||
|
||
public final class MainActivityStarter { | ||
private static final String STUDENT_PARCELER_KEY = "com.example.activitystarter.studentParcelerStarterKey"; | ||
|
||
public static void fill(MainActivity activity, Bundle savedInstanceState) { | ||
Intent intent = activity.getIntent(); | ||
if(savedInstanceState != null && savedInstanceState.containsKey(STUDENT_PARCELER_KEY)) { | ||
activity.studentParceler = (MainActivity.StudentParcel) org.parceler.Parcels.unwrap(savedInstanceState.getParcelable(STUDENT_PARCELER_KEY)); | ||
} else if(intent.hasExtra(STUDENT_PARCELER_KEY)) | ||
activity.studentParceler = (MainActivity.StudentParcel) org.parceler.Parcels.unwrap(intent.getParcelableExtra(STUDENT_PARCELER_KEY)); | ||
} | ||
|
||
public static void save(MainActivity activity, Bundle bundle) { | ||
bundle.putParcelable(STUDENT_PARCELER_KEY, org.parceler.Parcels.wrap(activity.studentParceler)); | ||
} | ||
|
||
public static Intent getIntent(Context context, MainActivity.StudentParcel studentParceler) { | ||
Intent intent = new Intent(context, MainActivity.class); | ||
intent.putExtra(STUDENT_PARCELER_KEY, org.parceler.Parcels.wrap(studentParceler)); | ||
return intent; | ||
} | ||
|
||
public static void start(Context context, MainActivity.StudentParcel studentParceler) { | ||
Intent intent = getIntent(context, studentParceler); | ||
context.startActivity(intent); | ||
} | ||
|
||
public static void startWithFlags(Context context, MainActivity.StudentParcel studentParceler, int flags) { | ||
Intent intent = getIntent(context, studentParceler); | ||
intent.addFlags(flags); | ||
context.startActivity(intent); | ||
} | ||
} |
Oops, something went wrong.